ToolMight LogoToolMight

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.

Difficulty:
Showing 31 problems
EasyArrays & Hashing
Visualizer

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.

2 approaches(O(n))
Learn logic
EasyArrays & Hashing
Visualizer

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.

2 approaches(O(n))
Learn logic
EasyArrays & Hashing
Visualizer

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.

2 approaches(O(n))
Learn logic
MediumArrays & Hashing
Visualizer

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.

1 approach(O(n))
Learn logic
MediumArrays & Hashing
Visualizer

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.

1 approach(O(n))
Learn logic
EasyArrays & Hashing
Visualizer

Linear Search

The foundational search algorithm for unsorted collections. Scans elements one by one until a match is found or the list is exhausted.

2 approaches(O(n))
Learn logic
EasyBinary Search
Visualizer

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.

2 approaches(O(log n))
Learn logic
MediumBinary Search
Visualizer

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.

1 approach(O(log n))
Learn logic
EasyTwo Pointers
Visualizer

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.

1 approach(O(n))
Learn logic
MediumTwo Pointers
Visualizer

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.

1 approach(O(n²))
Learn logic
MediumTwo Pointers
Visualizer

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.

1 approach(O(n))
Learn logic
HardTwo Pointers
Visualizer

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.

1 approach(O(n))
Learn logic
MediumSliding Window
Visualizer

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.

1 approach(O(n))
Learn logic
EasyStack
Visualizer

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.

1 approach(O(n))
Learn logic
MediumStack
Visualizer

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.

1 approach(O(1) for all operations)
Learn logic
EasyLinked List
Visualizer

Reverse Linked List

Reverse the directional arrows of a singly linked list in-place. The classic test of reference manipulation and memory pointer management.

2 approaches(O(n))
Learn logic
EasyLinked List
Visualizer

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.

1 approach(O(n + m))
Learn logic
EasyLinked List
Visualizer

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.

1 approach(O(n))
Learn logic
EasyTrees & BST
Visualizer

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.

1 approach(O(n))
Learn logic
EasyTrees & BST
Visualizer

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.

1 approach(O(n))
Learn logic
EasyTrees & BST
Visualizer

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.

1 approach(O(n * m))
Learn logic
MediumTrees & BST
Visualizer

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.

1 approach(O(n))
Learn logic
EasyTrees & BST
Visualizer

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.

1 approach(O(h))
Learn logic
MediumGraphs & Matrix Walks
Visualizer

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.

1 approach(O(m * n))
Learn logic
MediumGraphs & Matrix Walks
Visualizer

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.

1 approach(O(m * n))
Learn logic
MediumHeap & Priority Queue
Visualizer

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.

1 approach(O(n log k))
Learn logic
EasySliding Window
Visualizer

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.

1 approach(O(n))
Learn logic
MediumDynamic Programming
Visualizer

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.

1 approach(O(n))
Learn logic
EasyDynamic Programming
Visualizer

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.

1 approach(O(n))
Learn logic
MediumDynamic Programming
Visualizer

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.

1 approach(O(S * n))
Learn logic
MediumArrays & Hashing
Visualizer

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.

1 approach(O(n log n))
Learn logic