DSA & Programming Logic Problems
Learn core data structures and algorithmic patterns through comprehensive multi-approach explanations, underlying logic walkthroughs, asymptotic complexities, and multi-language code implementations connected to ToolMight's interactive visualizers.
Two Sum
Find the two numbers in an array that sum up to a target value. The quintessential problem for learning how to trade memory for speed using a Hash Map.
Contains Duplicate
Determine if any value appears at least twice in an integer array. A foundational problem for mastering constant-time hash lookups vs sorting trade-offs.
Valid Anagram
Determine whether two strings have the exact same character frequencies. A core problem demonstrating the power of fixed-size frequency buckets over O(n log n) sorting.
Product of Array Except Self
Return an array where output[i] is the product of all elements in nums except nums[i], without using the division operation in O(n) time.
Top K Frequent Elements
Return the k most frequent elements in an integer array. Master the Bucket Sort pattern to achieve linear O(n) runtime better than O(n log n) sorting.
Linear Search
The foundational search algorithm for unsorted collections. Scans elements one by one until a match is found or the list is exhausted.
Binary Search
Locate a target value in a sorted array in O(log n) logarithmic time. Like opening a dictionary in the middle, each comparison eliminates half the remaining items.
Search in Rotated Sorted Array
Search a rotated sorted array in O(log n) time. A masterclass in applying binary search when global order is broken: at least one half is always guaranteed to be sorted.
Valid Palindrome
Determine if a string is a palindrome considering only alphanumeric characters and ignoring case. The canonical problem for learning the two-pointer inward convergence technique.
3Sum
Find all unique triplets in an array that sum up to zero. The premier problem for learning how to combine sorting with two-pointer inward scans to avoid cubic brute force.
Container With Most Water
Find two vertical lines that together with the x-axis form a container holding the maximum amount of water. The premier problem for learning two-pointer greedy bottleneck elimination.
Trapping Rain Water
Given an elevation map where width of each bar is 1, compute how much water it can trap after raining. The classic masterclass in two-pointer bottleneck derivation.
Longest Substring Without Repeating Characters
Find the length of the longest substring containing no duplicate characters. The quintessential problem for mastering dynamic variable-size sliding windows.
Valid Parentheses
Verify that code brackets (), {}, and [] are properly closed and nested in order. This is the exact algorithm compilers, linters, and IDEs use to detect syntax errors in real-time.
Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant O(1) time. The premier problem for learning how to augment linear data structures with auxiliary state.
Reverse Linked List
Reverse the directional arrows of a singly linked list in-place. The classic test of reference manipulation and memory pointer management.
Merge Two Sorted Lists
Splice together nodes of two sorted linked lists into a single sorted list. The canonical problem for learning pointer reassignment and the dummy head technique.
Linked List Cycle
Determine if a linked list contains a cycle using Floyd's Tortoise and Hare algorithm. The foundational problem for understanding two-speed pointer convergence in finite loops.
Invert Binary Tree
Mirror-flip a binary tree so every left subtree swaps with the right subtree. The quintessential problem for mastering tree recursion and depth-first traversal.
Maximum Depth of Binary Tree
Find the maximum depth (height) of a binary tree along the longest path from root to leaf. The quintessential problem for learning bottom-up divide-and-conquer tree recursion.
Subtree of Another Tree
Determine if a binary tree contains a subtree identical in structure and node values to another tree. Learn how to combine outer tree DFS traversal with inner tree isomorphism matching.
Binary Tree Level Order Traversal
Return the level order traversal of a binary tree's node values from left to right, level by level. The premier problem for learning FIFO queue BFS level snapshots.
Lowest Common Ancestor of a Binary Search Tree
Find the lowest common ancestor (LCA) node of two given nodes in a Binary Search Tree. Exploit BST ordering properties to find the split point in O(h) time.
Number of Islands
Count the number of distinct islands in a 2D binary grid. The definitive problem for learning connected components and matrix flood-fill traversals.
Rotting Oranges
Determine the minimum minutes needed until all fresh oranges rot. The premier problem for learning Multi-Source Breadth-First Search (BFS) in grid matrices.
Kth Largest Element in an Array
Find the kth largest element in an unsorted array. The premier problem for learning Min-Heap bounded tracking and Quickselect partitioning.
Best Time to Buy and Sell Stock
Determine the maximum single-transaction profit from daily stock prices. A classic demonstration of how tracking a running minimum transforms an O(n²) pair search into an O(n) single pass.
Maximum Subarray (Kadane's Algorithm)
Find the contiguous slice of an array that yields the largest sum. Kadane's algorithm demonstrates the art of shedding negative historical baggage in O(n) linear time.
Climbing Stairs
Count the distinct ways to reach the top of an n-step staircase when hopping 1 or 2 steps at a time. The premier gentle introduction to Dynamic Programming and state transition.
Coin Change
Compute the fewest number of coins needed to make up a given amount. The quintessential problem for learning bottom-up dynamic programming tabulation and overlapping subproblems.
Merge Intervals
Merge all overlapping intervals and return an array of non-overlapping intervals that cover all inputs. The definitive problem for mastering interval scheduling and sorting by start time.