01 — Problem Directory

Data Structures & Algorithms

Complete catalog of 99 interactive algorithm visualizers. Browse by data structure category or filter by difficulty.

Showing 99 of 99 visualizers
LL
Linked Lists
Medium
Add Two Numbers

Add two numbers represented by linked lists in reverse digit order, simulating column-by-column addition with carry.

Linked ListMathTwo Pointers+1
ST
Stack
Medium
Asteroid Collision

Simulate asteroid collisions where positive asteroids move right and negative move left. Smaller asteroids explode upon impact.

StackSimulationArray
BT
Backtracking
Medium
Backtracking: Decision Tree & Constraints

Explore the universal backtracking template: watch the state space tree expand, witness constraint pruning terminate invalid branches early, and trace how choices are systematically undone.

BacktrackingDecision TreePruning+3
TR
Trees & BST
Easy
Balanced Binary Tree

Determine if a binary tree is height-balanced (depth of the two subtrees of every node never differs by more than 1).

DFSBinary TreeRecursion+2
ST
Stack
Easy
Baseball Game

Keep score for a baseball game by processing score records, invalidations, doubling, and additions using a stack.

StackArraySimulation+1
BT
Backtracking
Medium
Beautiful Arrangement

Count the number of permutations where either the number at position i is divisible by i, or i is divisible by the number, using recursive backtracking and divisibility pruning.

BacktrackingBit ManipulationRecursion+2
TR
Trees & BST
Medium
Binary Tree Level Order Traversal

Traverse binary tree nodes level-by-level from left to right using a FIFO queue (BFS).

BFSBinary TreeQueue+1
TR
Trees & BST
Hard
Binary Tree Maximum Path Sum

Find the maximum path sum along any sequence of nodes in a binary tree using bottom-up postorder DFS (ignoring negative subtrees).

DFSBinary TreeRecursion+3
BT
Backtracking
Easy
Binary Tree Paths

Find all root-to-leaf paths in a binary tree in any order using depth-first search and backtracking.

BacktrackingTreeDepth-First Search+1
TR
Trees & BST
Medium
Binary Tree Right Side View

Return the values of the nodes you can see ordered from top to bottom when standing on the right side of the binary tree.

BFSBinary TreeQueue+2
TR
Trees & BST
Medium
Binary Tree Zigzag Level Order Traversal

Traverse binary tree levels alternating directions (left-to-right on even levels, right-to-left on odd levels).

BFSBinary TreeQueue+2
ST
Stack
Medium
Car Fleet

Calculate the number of car fleets that will arrive at the target destination using arrival times and a monotonic stack.

StackSortingMonotonic Stack
AR
Arrays & Hashing
Easy
Check if Every Row and Column Contains All Numbers

An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive). Check validity using row and column hash sets.

ArrayHash TableMatrix
RC
Recursion & DP
Easy
Climbing Stairs (1D DP)

Calculate distinct ways to climb n stairs using top-down memoization, filling a 1D DP table.

Dynamic ProgrammingMemoizationFibonacci+1
RC
Recursion & DP
Easy
Climbing Stairs (Recursion Tree)

Visualize the recursive decision tree for climbing n stairs taking 1 or 2 steps at a time.

Recursion TreeDecision TreeFibonacci+1
BT
Backtracking
Medium
Combination Sum

Find all unique combinations of candidate numbers that sum to target using recursive backtracking on the decision tree.

BacktrackingRecursionArray+2
BT
Backtracking
Medium
Combination Sum II

Find all unique combinations in candidates that sum to target. Each number may only be used once, using duplicate skipping and branch pruning.

BacktrackingRecursionArray+2
BT
Backtracking
Medium
Combinations

Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n] using recursive backtracking on the decision tree.

BacktrackingRecursionCombinations+2
AR
Arrays & Hashing
Easy
Concatenation of Array

Given an integer array nums of length n, create and return an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n.

ArraySimulationTwo Pointers
AR
Arrays & Hashing
Medium
Container With Most Water

Find two lines that together with the x-axis form a container containing the most water using an optimal O(n) two-pointer inward scan.

Two PointersArrayGreedy+2
AR
Arrays & Hashing
Easy
Contains Duplicate

Detect duplicate elements in an array using an instant-lookup hash set.

Hash SetLookupFrequency
SW
Sliding Window
Easy
Contains Duplicate II

Determine if there are two distinct indices i and j such that nums[i] == nums[j] and abs(i - j) <= k using a sliding window hash set.

Sliding WindowHash SetArray
TR
Trees & BST
Medium
Count Complete Tree Nodes

Count nodes in a complete binary tree in less than O(n) time by comparing left and right subtree heights.

DFSBinary TreeBinary Search+2
TR
Trees & BST
Medium
Count Good Nodes in Binary Tree

Count the number of 'good' nodes in a binary tree (a node X is good if on the path from root to X there are no nodes with value greater than X).

DFSBinary TreeRecursion+2
ST
Stack
Medium
Daily Temperatures

Find the number of days you have to wait after the i-th day to get a warmer temperature using a monotonic decreasing stack.

Monotonic StackArray
AR
Arrays & Hashing
Easy
Design HashSet

Design a HashSet without using any built-in hash table libraries, demonstrating hashing (key % size) and collision resolution via separate chaining in dynamic buckets.

HashSetHashingSeparate Chaining+2
TR
Trees & BST
Easy
Diameter of Binary Tree

Compute the diameter (longest path between any two nodes) by finding max(leftDepth + rightDepth) at each node using postorder DFS.

DFSBinary TreeRecursion+2
AR
Arrays & Hashing
Medium
Dutch National Flag (Sort Colors)

Sort an array of 0s, 1s, and 2s in-place in linear time using Dijkstra's 3-way partitioning Dutch National Flag algorithm.

Two PointersSortingArray+1
ST
Stack
Medium
Evaluate Reverse Polish Notation

Evaluate arithmetic expressions written in Reverse Polish Notation (postfix) using a LIFO operand stack.

StackArrayMath+1
BS
Binary Search
Medium
Find Minimum in Rotated Sorted Array

Find the minimum element in a sorted rotated array in O(log n) time by comparing nums[mid] to nums[right].

Binary SearchRotated ArrayInflection Point
BT
Backtracking
Medium
Generate Parentheses

Generate all combinations of well-formed parentheses using recursive backtracking with open and close count pruning.

BacktrackingRecursionString+2
AR
Arrays & Hashing
Medium
Group Anagrams

Group strings together using sorted character keys in a hash map.

Hash MapSortingCategorization
BS
Binary Search
Easy
Guess Number Higher or Lower

Binary search to guess a secret picked number in range [1..n] in O(log n) using pre-defined guess() API feedback.

Binary SearchInteractive GameLeetCode 374
LL
Linked Lists
Easy
Linked List Cycle

Detect whether a linked list contains a cycle using Floyd's Tortoise and Hare algorithm.

Linked ListTwo PointersCycle Detection+1
TR
Trees & BST
Easy
Binary Tree Inorder Traversal

Visit binary tree nodes in Left -> Root -> Right order producing sorted order for Binary Search Trees.

DFSBinary TreeInorder+1
TR
Trees & BST
Easy
Invert Binary Tree

Invert a binary tree by recursively swapping the left and right child subtrees of every node.

DFSBinary TreeRecursion+1
AR
Arrays & Hashing
Easy
Valid Anagram

Check if two strings contain identical character frequency distributions.

Hash MapStringFrequency
BS
Binary Search
Medium
Koko Eating Bananas

Binary search on integer speed k in range [1 .. max(piles)] to find the minimum eating speed to finish all piles within h hours.

Binary Search on AnswerMonotonic Predicate
TR
Trees & BST
Medium
Kth Smallest Element in a BST

Find the kth smallest element (1-indexed) in a Binary Search Tree (BST) using in-order DFS traversal step counting.

BSTBinary Search TreeDFS+2
BT
Backtracking
Medium
Letter Combinations of a Phone Number

Generate all possible letter combinations that the input phone digits could represent using keypad mapping and recursive backtracking.

BacktrackingRecursionString+3
AR
Arrays & Hashing
Medium
Longest Consecutive Sequence

Find length of longest contiguous integer streak in O(n) using a hash set.

Hash SetStreakO(n)
SW
Sliding Window
Medium
Longest Repeating Character Replacement

Find the length of the longest substring containing the same letter you can get after performing at most k character replacements using a dynamic sliding window.

Sliding WindowTwo PointersFrequency Map
TR
Trees & BST
Medium
Lowest Common Ancestor of a Binary Search Tree

Find the lowest common ancestor (LCA) node of two given nodes p and q in a Binary Search Tree (BST) using value comparisons.

BSTBinary Search TreeDFS+2
TR
Trees & BST
Easy
Maximum Depth of Binary Tree

Find the maximum depth (height) of a binary tree by calculating 1 + max(leftDepth, rightDepth) recursively.

DFSBinary TreeRecursion+1
TR
Trees & BST
Medium
Maximum Width of Binary Tree

Calculate the maximum width among all levels of a binary tree by assigning 0-indexed position coordinates and normalizing each level against its starting index.

BFSBinary TreeQueue+2
AR
Arrays & Hashing
Medium
Merge Sort (Sort an Array)

Sort an array of integers in ascending order using divide-and-conquer Merge Sort with O(n log n) time complexity.

Divide and ConquerMerge SortRecursion+2
AR
Arrays & Hashing
Easy
Merge Sorted Array

Merge two sorted integer arrays into nums1 as one sorted array using two pointers and an auxiliary merge buffer.

Two PointersArraySorting
AR
Arrays & Hashing
Easy
Merge Strings Alternately

Merge characters from word1 and word2 in alternating order, appending any remaining suffix characters.

Two PointersStringSimulation
LL
Linked Lists
Easy
Merge Two Sorted Lists

Merge two sorted linked lists into a single sorted list by splicing together node pointers in O(n + m) time.

Linked ListTwo PointersSimulation
LL
Linked Lists
Easy
Middle of the Linked List

Find the middle node of a singly linked list using fast and slow pointers.

Linked ListTwo PointersFast & Slow Pointers
HP
Heap / Priority Queue
Medium
Min Heap (Heapify Up & Down)

Complete binary min-heap implementation visualizing _heapifyUp() on insertion and _heapifyDown() on root extraction across both binary tree and 0-indexed array representations.

Min HeapBinary HeapHeapify Up+3
ST
Stack
Medium
Min Stack

Design a stack supporting push, pop, top, and retrieving the minimum element in constant O(1) time using an auxiliary monotonic min-tracker stack.

StackDesignMonotonic Stack+1
SW
Sliding Window
Medium
Minimum Size Subarray Sum

Find the minimal length of a contiguous subarray of which the sum is greater than or equal to target using a dynamic sliding window.

ArrayBinary SearchSliding Window+1
AR
Arrays & Hashing
Easy
Move Zeroes

Move all zeros in an array to the end in-place while maintaining the relative order of the non-zero elements using two pointers.

Two PointersArrayIn-Place
ST
Stack
Easy
Next Greater Element I

Find the next greater element for each number in nums1 within nums2 using a monotonic stack and hash map.

Monotonic StackHash MapArray
ST
Stack
Medium
Next Greater Element II

Find the next greater numeric element for every number in a circular integer array using a monotonic decreasing stack over two passes.

StackMonotonic StackArray+1
LL
Linked Lists
Medium
Odd Even Linked List

Group all nodes with odd indices together followed by nodes with even indices in O(1) space and O(n) time.

Linked ListTwo PointersIn-Place
ST
Stack
Medium
Online Stock Span

Calculate the span of stock prices in an online stream using a monotonic decreasing stack tracking [price, span] pairs.

StackMonotonic StackDesign+1
LL
Linked Lists
Easy
Palindrome Linked List

Determine if a singly linked list is a palindrome in O(n) time and O(1) space using fast/slow pointers and in-place reversal.

Linked ListTwo PointersFast & Slow Pointers+1
BT
Backtracking
Medium
Palindrome Partitioning

Partition a string such that every substring of the partition is a palindrome using backtracking and two-pointer palindrome validation.

BacktrackingTwo PointersString+2
LL
Linked Lists
Medium
Partition List

Partition a linked list such that all nodes less than x come before nodes greater than or equal to x, preserving relative order.

Linked ListTwo PointersPartition
TR
Trees & BST
Easy
Path Sum

Determine if the binary tree has a root-to-leaf path such that adding up all values along the path equals targetSum.

DFSBinary TreeRecursion+2
TR
Trees & BST
Medium
Path Sum II

Find all unique root-to-leaf paths where the sum of the node values equals targetSum using DFS backtracking.

DFSBinary TreeRecursion+2
BT
Backtracking
Medium
Permutations

Generate all possible permutations of an array of distinct integers using recursive backtracking and a visited set.

BacktrackingRecursionPermutations+2
TR
Trees & BST
Easy
Binary Tree Postorder Traversal

Visit binary tree nodes in Left -> Right -> Root order for bottom-up calculation and subtree evaluation.

DFSBinary TreePostorder+1
TR
Trees & BST
Easy
Binary Tree Preorder Traversal

Visit binary tree nodes in Root -> Left -> Right order using DFS recursion and call stack unwinding.

DFSBinary TreeRecursion+1
AR
Arrays & Hashing
Medium
Range Sum Query 2D - Immutable

Precompute a 2D prefix sum matrix in O(m · n) time to evaluate any submatrix sum query in O(1) time using the 2D Inclusion-Exclusion Principle.

Prefix SumMatrixDesign+1
AR
Arrays & Hashing
Easy
Range Sum Query - Immutable

Precompute prefix sums in O(n) to evaluate contiguous subarray sum queries in constant O(1) time.

Prefix SumArrayDesign
ST
Stack
Easy
Remove All Adjacent Duplicates In String

Repeatedly remove adjacent, duplicate character pairs from a string using a LIFO stack until no duplicates remain.

StackStringAdjacent Duplicates+1
LL
Linked Lists
Easy
Remove Duplicates from Sorted List

Delete all duplicate elements from a sorted singly linked list so each element appears only once.

Linked ListTwo Pointers
LL
Linked Lists
Medium
Remove Nth Node From End of List

Remove the n-th node from the end of the list and return its head using a one-pass two-pointer approach with a dummy node.

Linked ListTwo PointersDummy Node
LL
Linked Lists
Medium
Reorder List

Reorder the list to L0 → Ln → L1 → Ln-1 → L2 → Ln-2 by finding the middle, reversing the second half, and merging both halves.

Linked ListTwo PointersReversal+1
BT
Backtracking
Medium
Restore IP Addresses

Generate all possible valid IPv4 addresses by partitioning a string into four octets (0-255 without leading zeros) using recursive backtracking.

BacktrackingStringRecursion+1
LL
Linked Lists
Easy
Reverse Linked List

Reverse a singly linked list iteratively in-place by reversing the next pointer of each node.

Linked ListTwo PointersIterative+1
LL
Linked Lists
Medium
Reverse Linked List II

Reverse a singly linked list from position left to position right in a single pass.

Linked ListTwo PointersIterative+1
RC
Recursion & DP
Easy
Reverse String

Reverse a character array in-place using recursive two-pointer swap and call stack unwinding.

Call StackRecursionTwo Pointers
LL
Linked Lists
Medium
Rotate List

Rotate the linked list to the right by k places by connecting the tail to head and severing at (length - k % length).

Linked ListTwo PointersCircular List
TR
Trees & BST
Easy
Same Tree

Check if two binary trees are structurally identical and have the same node values using simultaneous DFS recursion.

DFSBinary TreeRecursion+1
BS
Binary Search
Medium
Search a 2D Matrix

Treat an m x n row-sorted matrix as a virtual 1D sorted array [0 .. m*n - 1] and perform binary search.

Binary Search2D MatrixCoordinate Mapping
BS
Binary Search
Easy
Search Insert Position

Find target index or insertion position in sorted array using binary search [left, right].

Binary SearchRange Halving
BS
Binary Search
Medium
Search in Rotated Sorted Array

Find target index in a rotated sorted array in O(log n) time by finding the pivot (minimum element) and binary searching the target segment.

Binary SearchRotated ArrayTwo Phase
BS
Binary Search
Medium
Capacity To Ship Packages Within D Days

Binary search on candidate ship capacity in range [max(weights) .. sum(weights)] to find minimum capacity feasible within D days.

Binary Search on AnswerGreedy Simulation
ST
Stack
Medium
Simplify Path

Convert an absolute Unix-style file path into its canonical simplified form using a LIFO stack to manage directory navigation, parent traversals, and redundant slashes.

StackStringUnix Path+2
LL
Linked Lists
Medium
Sort List

Sort a linked list in O(n log n) time using top-down Merge Sort with divide-and-conquer recursion.

Linked ListMerge SortDivide and Conquer+1
AR
Arrays & Hashing
Easy
Squares of a Sorted Array

Square numbers and sort in O(n) time using opposing two pointers.

Two PointersSorted Array
BT
Backtracking
Medium
Subsets

Generate all possible subsets (the power set) of a distinct integer array using recursive backtracking on the decision tree.

BacktrackingRecursionPower Set+2
BT
Backtracking
Medium
Subsets II

Generate all unique subsets from an integer array that may contain duplicates using sorting, duplicate skipping, and recursive backtracking.

BacktrackingRecursionArray+2
TR
Trees & BST
Easy
Subtree of Another Tree

Check if binary tree subRoot is a subtree of root with identical structure and node values.

DFSBinary TreeRecursion+2
TR
Trees & BST
Medium
Sum Root to Leaf Numbers

Calculate the total sum of all numbers formed along root-to-leaf paths (each path represents a decimal number).

DFSBinary TreeRecursion+1
LL
Linked Lists
Medium
Swap Nodes in Pairs

Swap every two adjacent nodes in a linked list and return its head without modifying node values.

Linked ListRecursionPointer Manipulation
TR
Trees & BST
Easy
Symmetric Tree

Check whether a binary tree is a mirror of itself (symmetric around its center) using simultaneous dual-pointer DFS recursion.

DFSBinary TreeRecursion+2
AR
Arrays & Hashing
Medium
3Sum

Find all unique triplets that sum to zero with sorting and two pointers.

Two PointersSortingDuplicate Handling
AR
Arrays & Hashing
Easy
Two Sum

Find indices of two numbers that add up to target using a single-pass hash map.

Hash MapArrayComplement
AR
Arrays & Hashing
Medium
Two Sum II (Sorted Array)

Find two numbers in a 1-indexed sorted array that add up to a target number using opposing two pointers in O(n) time and O(1) space.

Two PointersArrayBinary Search+1
AR
Arrays & Hashing
Easy
Valid Palindrome II

Determine if a string can be a palindrome after deleting at most one character using two pointers.

Two PointersStringGreedy
ST
Stack
Easy
Valid Parentheses

Determine if an input string containing '(', ')', '{', '}', '[' and ']' is valid using a LIFO stack.

StackStringMatching
AR
Arrays & Hashing
Medium
Valid Sudoku

Validate a 9x9 Sudoku board checking rows, columns, and 3x3 subgrids.

Hash SetMatrixValidation
TR
Trees & BST
Medium
Validate Binary Search Tree

Determine if a binary tree is a valid Binary Search Tree (BST) where every node satisfies min < node.val < max recursively.

BSTBinary Search TreeDFS+2
BT
Backtracking
Medium
Word Search

Determine if a target word exists in a 2D grid of characters by constructing a path of adjacent cells without reusing any cell.

BacktrackingMatrixDFS+1