Every algorithm starts with a structure

Before sorting, searching, or backtracking - understand what you are operating on. Here is the lineup, roughly in the order most courses teach them.

01
📦

Array

A contiguous block of memory holding elements in order. Indexing is instant because the address of any element is just base + i times size - no searching required.

3
9
2
7
5
Access O(1)Insert O(n)Search O(n)
02
🔗

Linked List

Nodes scattered in memory, each pointing to the next. Trades fast indexing for fast insertion - adding a node is just rewiring two pointers, no shifting required.

3
->
9
->
2
->
∅
Access O(n)Insert O(1)Search O(n)
03
🔤

String

A sequence of characters, usually array-backed and immutable in most languages. Concatenation, slicing, and pattern matching all build on simple character indexing.

C
O
D
E
Access O(1)Concat O(n)Search O(n)
04
🥞

Stack

Last in, first out. You only ever touch the top - push to add, pop to remove. Powers undo history, call stacks, and depth-first traversal.

bottom - 4
12
top - 9
Push O(1)Pop O(1)Peek O(1)
05
🚶

Queue

First in, first out - exactly like a line at a counter. Enqueue at the back, dequeue from the front. The backbone of breadth-first traversal and task scheduling.

front
5
8
1
back
Enqueue O(1)Dequeue O(1)Peek O(1)
06
⇆

Deque

A double-ended queue - insert or remove from either the front or the back in O(1). More flexible than a plain queue or stack, and often the engine behind sliding-window problems.

front
5
8
1
back
Push front O(1)Push back O(1)Peek O(1)
07
🌳

Tree

A hierarchy of nodes with one root and no cycles. Binary search trees keep smaller values left and larger right, turning search into a series of left/right decisions.

8 4 12 2
Search O(log n)Insert O(log n)Balanced
08
🕸

Graph

Nodes (vertices) connected by edges, with no fixed shape - trees, networks, and maps are all graphs. Traversed with BFS for shortest hops or DFS for full exploration.

A B C D
BFS O(V+E)DFS O(V+E)Cyclic OK
09
🔑

Hash Table

A key is run through a hash function that maps it to a bucket index, giving near-instant lookup. Collisions (two keys, same bucket) are resolved with chaining or probing - the reason worst-case lookup can degrade to O(n).

"cat" hash() 2 bucket 0 bucket 1 - "dog" bucket 2 - "cat" * bucket 3
Average lookup O(1)Worst case O(n)Insert avg O(1)

Problem library

Step through each technique frame by frame - classic LeetCode patterns rendered as live, controllable animations.

Pattern:

SortingEasy

Bubble Sort

Repeatedly swap adjacent out-of-order pairs until the largest values bubble to the end.

Watch animation
SortingEasy

Insertion Sort

Build a sorted prefix one element at a time, inserting each new value into its correct slot.

Watch animation
SortingMedium

Merge Sort

Divide the array in half recursively, then merge sorted halves back together in linear time.

Watch animation
SortingMedium

Quick Sort

Pick a pivot element and partition the array around it, then recursively sort each side.

Watch animation
SortingEasy

Selection Sort

Repeatedly find the minimum element from the unsorted part and swap it into place.

Watch animation
ArrayEasy

Merge Sorted Arrays

Merge two already-sorted arrays into one using two pointers, in place, in a single pass.

Watch animation
ArrayMedium

Dutch National Flag

Sort an array of three distinct values into three regions using a single pass with three pointers.

Watch animation
ArrayMedium

Count Inversions

Count out-of-order pairs by piggybacking on merge sort merge step - no brute force needed.

Watch animation
ArrayMedium

Next Permutation

Rearrange numbers into the lexicographically next greater permutation, in place.

Watch animation
ArrayEasy

Peak Index in Mountain Array

Find the peak element index inside a mountain-shaped array via binary search.

Watch animation
ArrayMedium

Reverse Words in a String

Reverse the order of words in a string in-place without using extra space for a new string.

Watch animation
ArrayMedium

Search in Rotated Sorted Array

Find a target in a sorted array that was rotated at some unknown pivot using binary search.

Watch animation
ArrayMedium

Search a 2D Matrix I (LeetCode 74)

Treat a row-sorted matrix as a flattened sorted array to search in O(log(m times n)) time.

Watch animation
ArrayMedium

Search a 2D Matrix II (LeetCode 240)

Search a row and column sorted matrix by starting from top-right and eliminating rows/columns.

Watch animation
ArrayMedium

Single Element in a Sorted Array

Find the only element that appears once in a sorted array where every other element appears twice.

Watch animation
ArrayHard

Sliding Window Maximum

Find the maximum in every contiguous subarray of size k using a deque for O(n) time.

Watch animation
ArrayMedium

Spiral Matrix (LeetCode 54)

Traverse a 2D matrix in a clockwise spiral order, shrinking boundaries as you go.

Watch animation
ArrayHard

Split Array Largest Sum

Split an array into m subarrays to minimize the largest sum, solved with binary search.

Watch animation
ArrayMedium

String Compression (LeetCode 443)

Compress consecutive repeating characters in-place using two pointers and count encoding.

Watch animation
ArrayMedium

Subarray Sum Equals K

Count contiguous subarrays that sum to K using a hashmap to store prefix sums.

Watch animation
ArrayMedium

3Sum

Find all unique triplets in an array that sum to zero using sorting and two pointers.

Watch animation
ArrayHard

Trapping Rain Water

Compute trapped water between elevation bars using two pointers and precomputed max heights.

Watch animation
ArrayMedium

Pow(x, n)

Compute x raised to the power n efficiently using binary exponentiation (exponentiation by squaring).

Watch animation
ArrayMedium

Book Allocation

Allocate books to students such that the maximum pages assigned is minimized using binary search.

Watch animation
Linked ListMedium

Detect Cycle in Linked List

Use Floyd Tortoise and Hare algorithm to detect if a linked list contains a cycle in O(n) time.

Watch animation
Linked ListEasy

Reverse Linked List

Reverse a singly linked list iteratively by rewiring next pointers from head to tail.

Watch animation
Linked ListMedium

Reverse Linked List II

Reverse only the nodes from position m to n in a linked list in one pass.

Watch animation
BacktrackingMedium

All Subsets

Generate every possible subset of a set by branching include/exclude choices for each element.

Watch animation
BacktrackingMedium

Combination Sum

Find every combination of candidates that adds up to a target, reusing numbers as needed.

Watch animation
BacktrackingHard

N-Queens

Place N chess queens on an N by N chessboard so that no two queens threaten each other.

Watch animation
BacktrackingMedium

Permutations (LeetCode 46)

Generate all possible permutations from a collection of distinct integers using backtracking.

Watch animation
BacktrackingHard

Sudoku Solver

Solve a partially filled 9 by 9 Sudoku board by trying digits 1-9 and backtracking on conflicts.

Watch animation
BacktrackingHard

Knight Tour

Find a sequence of moves for a knight to visit every square on a chessboard exactly once.

Watch animation
BacktrackingMedium

Generate Parentheses

Generate all combinations of well-formed parentheses for a given number of pairs.

Watch animation
DPMedium

Kadane Algorithm

Find the maximum sum contiguous subarray in one pass by tracking a running local maximum.

Watch animation
DPEasy

Best Time to Buy and Sell Stock

Find the maximum profit from a single buy and sell by tracking the minimum price seen so far.

Watch animation
DPMedium

Stone Game (LeetCode 877)

Determine if the first player can win a turn-based game where players pick stones from ends.

Watch animation
DPMedium

House Robber

Maximize stolen money from houses in a line without robbing two adjacent houses using DP.

Watch animation
DPMedium

House Robber II

House Robber variant where houses are arranged in a circle - first and last are adjacent.

Watch animation
DPMedium

Triangle Minimum Path Sum

Find the minimum path sum from top to bottom in a triangle array using bottom-up DP.

Watch animation
StackEasy

Valid Parentheses

Check if a string of brackets is valid using a stack to match opening and closing pairs.

Watch animation
Hash TableMedium

Group Anagrams (LeetCode 49)

Group strings that are anagrams of each other by using a sorted character key as hash key.

Watch animation
ArrayMedium

Fastslowpointers

Interactive step-by-step animation of Fastslowpointers.

Watch animation
ArrayMedium

Maxproductsubarray

Interactive step-by-step animation of Maxproductsubarray.

Watch animation
ArrayMedium

Prefix2d

Interactive step-by-step animation of Prefix2d.

Watch animation
ArrayMedium

Prefixsum

Interactive step-by-step animation of Prefixsum.

Watch animation
ArrayMedium

Prefixxor

Interactive step-by-step animation of Prefixxor.

Watch animation
ArrayMedium

Search 2d Matrix 1 2

Interactive step-by-step animation of Search 2d Matrix 1 2.

Watch animation
ArrayMedium

Subarraygivenxor

Interactive step-by-step animation of Subarraygivenxor.

Watch animation
ArrayMedium

Variableslidingwindow

Interactive step-by-step animation of Variableslidingwindow.

Watch animation
Bit ManipulationMedium

Bit Checks

Interactive step-by-step animation of Bit Checks.

Watch animation
Bit ManipulationMedium

Bit Masking

Interactive step-by-step animation of Bit Masking.

Watch animation
Bit ManipulationMedium

Prefix Xor

Interactive step-by-step animation of Prefix Xor.

Watch animation
Bit ManipulationMedium

Subarraygivenxor

Interactive step-by-step animation of Subarraygivenxor.

Watch animation
Bit ManipulationMedium

Subset via Bits

Interactive step-by-step animation of Subset via Bits.

Watch animation
Bit ManipulationMedium

Xor Pattern

Interactive step-by-step animation of Xor Pattern.

Watch animation
DPMedium

Dp 1d

Interactive step-by-step animation of Dp 1d.

Watch animation
DPMedium

Dp 2d

Interactive step-by-step animation of Dp 2d.

Watch animation
DPHard

Dp Bitmask

Interactive step-by-step animation of Dp Bitmask.

Watch animation
DPMedium

Dp Decision

Interactive step-by-step animation of Dp Decision.

Watch animation
DPHard

Dp Digit

Interactive step-by-step animation of Dp Digit.

Watch animation
DPMedium

Dp Grid

Interactive step-by-step animation of Dp Grid.

Watch animation
DPMedium

Dp Interval

Interactive step-by-step animation of Dp Interval.

Watch animation
DPMedium

Dp Knapsack

Interactive step-by-step animation of Dp Knapsack.

Watch animation
DPMedium

Dp Linear

Interactive step-by-step animation of Dp Linear.

Watch animation
DPMedium

Dp Memo Vs Tab

Interactive step-by-step animation of Dp Memo Vs Tab.

Watch animation
DPMedium

Dp Partition

Interactive step-by-step animation of Dp Partition.

Watch animation
DPMedium

Dp Sequence

Interactive step-by-step animation of Dp Sequence.

Watch animation
DPMedium

Dp Trees

Interactive step-by-step animation of Dp Trees.

Watch animation
GraphMedium

Bfs Rotting Oranges

Interactive step-by-step animation of Bfs Rotting Oranges.

Watch animation
GraphMedium

Dfs Number of Islands

Interactive step-by-step animation of Dfs Number of Islands.

Watch animation
GraphMedium

Cycle Detection Directed

Interactive step-by-step animation of Cycle Detection Directed.

Watch animation
GraphMedium

Cycle Detection Undirected

Interactive step-by-step animation of Cycle Detection Undirected.

Watch animation
GraphMedium

Topological Sort Kahn

Interactive step-by-step animation of Topological Sort Kahn.

Watch animation
GraphMedium

Topological Sort Dfs

Interactive step-by-step animation of Topological Sort Dfs.

Watch animation
GraphMedium

Dijkstra Network Delay

Interactive step-by-step animation of Dijkstra Network Delay.

Watch animation
GraphMedium

Bellman Ford

Interactive step-by-step animation of Bellman Ford.

Watch animation
GraphMedium

Floyd Warshall

Interactive step-by-step animation of Floyd Warshall.

Watch animation
GraphMedium

Kruskal Mst

Interactive step-by-step animation of Kruskal Mst.

Watch animation
GraphMedium

Prim Mst

Interactive step-by-step animation of Prim Mst.

Watch animation
GraphMedium

Union Find Dsu

Interactive step-by-step animation of Union Find Dsu.

Watch animation
GraphMedium

Bipartite Check

Interactive step-by-step animation of Bipartite Check.

Watch animation
GreedyMedium

Activity Selection

Interactive step-by-step animation of Activity Selection.

Watch animation
GreedyMedium

Deadline Scheduling

Interactive step-by-step animation of Deadline Scheduling.

Watch animation
GreedyMedium

Huffman Merge Cost

Interactive step-by-step animation of Huffman Merge Cost.

Watch animation
GreedyMedium

Jump Game

Interactive step-by-step animation of Jump Game.

Watch animation
GreedyMedium

Minimum Platforms

Interactive step-by-step animation of Minimum Platforms.

Watch animation
GreedyMedium

Non Overlapping Intervals

Interactive step-by-step animation of Non Overlapping Intervals.

Watch animation
Hash TableEasy

Firstuniquecharacter

Interactive step-by-step animation of Firstuniquecharacter.

Watch animation
Hash TableMedium

Longestconsecutive

Interactive step-by-step animation of Longestconsecutive.

Watch animation
Hash TableMedium

Next Smaller Element

Interactive step-by-step animation of Next Smaller Element.

Watch animation
Hash TableMedium

Top K Frequent 347

Interactive step-by-step animation of Top K Frequent 347.

Watch animation
Hash TableEasy

Twosum

Interactive step-by-step animation of Twosum.

Watch animation
HeapMedium

Heap Huffman Encoding

Interactive step-by-step animation of Heap Huffman Encoding.

Watch animation
HeapMedium

Heap K Way Merge

Interactive step-by-step animation of Heap K Way Merge.

Watch animation
HeapMedium

Heap Meeting Rooms

Interactive step-by-step animation of Heap Meeting Rooms.

Watch animation
HeapMedium

Heap Reorganize String

Interactive step-by-step animation of Heap Reorganize String.

Watch animation
HeapMedium

Heap Task Scheduler

Interactive step-by-step animation of Heap Task Scheduler.

Watch animation
HeapMedium

Heap Top K Kth Closest

Interactive step-by-step animation of Heap Top K Kth Closest.

Watch animation
Linked ListMedium

Floyd Cycle Detection

Interactive step-by-step animation of Floyd Cycle Detection.

Watch animation
Linked ListMedium

Merge Two Sorted Lists

Interactive step-by-step animation of Merge Two Sorted Lists.

Watch animation
Linked ListEasy

Middle of Linked List

Interactive step-by-step animation of Middle of Linked List.

Watch animation
Linked ListMedium

Reverse K Group

Interactive step-by-step animation of Reverse K Group.

Watch animation
Linked ListEasy

Reverse Linked List

Interactive step-by-step animation of Reverse Linked List.

Watch animation
Queue/DequeMedium

Bfs Queue Traversal

Interactive step-by-step animation of Bfs Queue Traversal.

Watch animation
Queue/DequeEasy

Circular Queue

Interactive step-by-step animation of Circular Queue.

Watch animation
Queue/DequeMedium

Deque Based

Interactive step-by-step animation of Deque Based.

Watch animation
Queue/DequeMedium

Level Order Traversal

Interactive step-by-step animation of Level Order Traversal.

Watch animation
RecursionMedium

Backtracking Template

Interactive step-by-step animation of Backtracking Template.

Watch animation
RecursionMedium

Subsets Power Set

Interactive step-by-step animation of Subsets Power Set.

Watch animation
RecursionMedium

Permutations

Interactive step-by-step animation of Permutations.

Watch animation
RecursionMedium

Combinations

Interactive step-by-step animation of Combinations.

Watch animation
RecursionMedium

Word Search

Interactive step-by-step animation of Word Search.

Watch animation
RecursionMedium

Palindrome Partitioning

Interactive step-by-step animation of Palindrome Partitioning.

Watch animation
RecursionMedium

Quick Select

Interactive step-by-step animation of Quick Select.

Watch animation
RecursionMedium

Count Inversions

Interactive step-by-step animation of Count Inversions.

Watch animation
RecursionMedium

N Queens

Interactive step-by-step animation of N Queens.

Watch animation
SortingMedium

Bucket Sort

Interactive step-by-step animation of Bucket Sort.

Watch animation
SortingMedium

Counting Sort

Interactive step-by-step animation of Counting Sort.

Watch animation
SortingMedium

Heap Sort

Interactive step-by-step animation of Heap Sort.

Watch animation
SortingMedium

Radix Sort

Interactive step-by-step animation of Radix Sort.

Watch animation
StackMedium

Evaluate Rpn

Interactive step-by-step animation of Evaluate Rpn.

Watch animation
StackHard

Largest Rectangle Histogram

Interactive step-by-step animation of Largest Rectangle Histogram.

Watch animation
StackMedium

Min Max Stack

Interactive step-by-step animation of Min Max Stack.

Watch animation
StackMedium

Next Greater Element

Interactive step-by-step animation of Next Greater Element.

Watch animation
StackMedium

Next Smaller Element

Interactive step-by-step animation of Next Smaller Element.

Watch animation
StackMedium

Previous Greater Element

Interactive step-by-step animation of Previous Greater Element.

Watch animation
StackMedium

Stock Span

Interactive step-by-step animation of Stock Span.

Watch animation
StringMedium

Kmp

Interactive step-by-step animation of Kmp.

Watch animation
StringMedium

Longestconsecutive

Interactive step-by-step animation of Longestconsecutive.

Watch animation
StringMedium

Minimumwindowsubstring

Interactive step-by-step animation of Minimumwindowsubstring.

Watch animation
StringEasy

Palindromecheck

Interactive step-by-step animation of Palindromecheck.

Watch animation
StringMedium

Permutationinstring

Interactive step-by-step animation of Permutationinstring.

Watch animation
StringMedium

Rabinkarp

Interactive step-by-step animation of Rabinkarp.

Watch animation
StringMedium

Variableslidingwindow

Interactive step-by-step animation of Variableslidingwindow.

Watch animation
StringMedium

Zalgorithm

Interactive step-by-step animation of Zalgorithm.

Watch animation
TreeMedium

Tree Bfs Variants

Interactive step-by-step animation of Tree Bfs Variants.

Watch animation
TreeMedium

Tree Dfs Traversals

Interactive step-by-step animation of Tree Dfs Traversals.

Watch animation
TreeMedium

Tree Diameter Height Depth

Interactive step-by-step animation of Tree Diameter Height Depth.

Watch animation
TreeMedium

Tree Max Path Sum

Interactive step-by-step animation of Tree Max Path Sum.

Watch animation
TreeMedium

Tree Recursion Bottom Up

Interactive step-by-step animation of Tree Recursion Bottom Up.

Watch animation
TreeMedium

Tree Recursion Top Down

Interactive step-by-step animation of Tree Recursion Top Down.

Watch animation
TrieMedium

Trie Bitwise

Interactive step-by-step animation of Trie Bitwise.

Watch animation
TrieMedium

Trie Insert Search

Interactive step-by-step animation of Trie Insert Search.

Watch animation
TrieMedium

Trie Prefix Match

Interactive step-by-step animation of Trie Prefix Match.

Watch animation

Complexity at a glance

Big-O for every animation in the gallery above.

Algorithm Time Space
Bubble SortO(n^2)O(1)
Insertion SortO(n^2)O(1)
Merge SortO(n log n)O(n)
Quick SortO(n log n)O(log n)
Selection SortO(n^2)O(1)
Merge Sorted ArraysO(n + m)O(1)
Dutch National FlagO(n)O(1)
Count InversionsO(n log n)O(n)
Next PermutationO(n)O(1)
Peak Index in Mountain ArrayO(log n)O(1)
Reverse Words in StringO(n)O(n)
Search Rotated ArrayO(log n)O(1)
Search a 2D Matrix IO(log(m x n))O(1)
Search a 2D Matrix IIO(m + n)O(1)
Single Element SortedO(log n)O(1)
Sliding Window MaximumO(n)O(k)
Spiral Matrix (54)O(m x n)O(1)
Split Array Largest SumO(n log(sum))O(1)
String Compression (443)O(n)O(1)
Subarray Sum Equals KO(n)O(n)
3SumO(n^2)O(n)
Trapping Rain WaterO(n)O(1)
Pow(x, n)O(log n)O(log n)
Book AllocationO(n log(sum))O(1)
Detect Cycle Linked ListO(n)O(1)
Reverse Linked ListO(n)O(1)
Reverse Linked List IIO(n)O(1)
All SubsetsO(2^n)O(n)
Combination SumO(2^n)O(target)
N-QueensO(N!)O(N^2)
Permutations (46)O(n x n!)O(n!)
Sudoku SolverO(9^m)O(81)
Knight TourO(8^(N^2))O(N^2)
Generate ParenthesesO(4^n / sqrt(n))O(n)
Kadane AlgorithmO(n)O(1)
Stock Buy SellO(n)O(1)
Stone Game (877)O(n^2)O(n^2)
House RobberO(n)O(1)
House Robber IIO(n)O(1)
Triangle Min PathO(n^2)O(n)
Valid ParenthesesO(n)O(n)
Group Anagrams (49)O(n x k log k)O(n x k)
FastslowpointersO(N)O(1)
MaxproductsubarrayO(N)O(1)
Prefix2dO(R x C)O(1)
PrefixsumO(N)O(N)
PrefixxorO(N)O(N)
Search 2d Matrix 1 2O(log(m x n))O(m + n)
SubarraygivenxorO(N)O(N)
VariableslidingwindowO(N)O(k)
Bit ChecksO(1)O(K)
Bit MaskingO(1)O(K)
Prefix XorO(N)O(N)
Subset via BitsO(N x 2^N)O(N x 2^N)
Xor PatternO(N)O(1)
Dp 1dO(N)O(N) / O(1)
Dp 2dO(M x N)O(M x N)
Dp BitmaskO(2^N x N^2)O(2^N x N)
Dp DecisionO(N)O(1)
Dp DigitO(D x 10 x S)O(D x S)
Dp GridO(M x N)O(1)
Dp IntervalO(N^2)O(N^2)
Dp KnapsackO(N x W)O(N x W)
Dp LinearO(N^2)O(N)
Dp Memo Vs TabO(n)O(n) / O(1)
Dp PartitionO(N^2)O(N^2)
Dp SequenceO(M x N)O(M x N)
Dp TreesO(N)O(H)
Bfs Rotting OrangesO(R x C)O(R x C)
Dfs Number of IslandsO(R x C)O(R x C)
Cycle Detection DirectedO(V + E)O(V + E)
Cycle Detection UndirectedO(V + E)O(V)
Topological Sort KahnO(V + E)O(V)
Topological Sort DfsO(V + E)O(V)
Dijkstra Network DelayO(E log V)O(V + E)
Bellman FordO(V x E)O(V)
Floyd WarshallO(V^3)O(V^2)
Kruskal MstO(E log E)O(V)
Prim MstO(E log V)O(V + E)
Union Find DsuO(E x a(V))O(V)
Bipartite CheckO(V + E)O(V)
Activity SelectionO(N log N)O(1)
Deadline SchedulingO(N x D)O(D)
Huffman Merge CostO(N log N)O(N)
Jump GameO(N)O(1)
Minimum PlatformsO(N log N)O(1)
Non Overlapping IntervalsO(N log N)O(1)
FirstuniquecharacterO(N)O(K)
LongestconsecutiveO(N)O(N)
Next Smaller ElementO(N)O(N)
Top K Frequent 347O(N)O(N)
TwosumO(N)O(N)
Heap Huffman EncodingO(N log N)O(N)
Heap K Way MergeO(N log K)O(K)
Heap Meeting RoomsO(N log N)O(N)
Heap Reorganize StringO(N log 26)O(26)
Heap Task SchedulerO(T log 26)O(26)
Heap Top K Kth ClosestO(N log K)O(K)
Floyd Cycle DetectionO(N)O(1)
Merge Two Sorted ListsO(N+M)O(1)
Middle of Linked ListO(N)O(1)
Reverse K GroupO(N)O(1)
Bfs Queue TraversalO(V + E)O(V)
Circular QueueO(1)O(k)
Deque BasedO(N)O(k)
Level Order TraversalO(N)O(N)
Backtracking TemplateO(2^n x n)O(n)
Subsets Power SetO(2^n x n)O(n)
PermutationsO(n! x n)O(n)
CombinationsO(C(n,k) x k)O(k)
Word SearchO(mxnx4^L)O(L)
Palindrome PartitioningO(2^n x n)O(n)
Quick SelectO(n) avg / O(n^2) worstO(1)
N QueensO(N!)O(N)
Bucket SortO(N + K)O(N + K)
Counting SortO(N + K)O(N + K)
Heap SortO(N log N)O(1)
Radix SortO(D x (N+K))O(N + K)
Evaluate RpnO(N)O(N)
Largest Rectangle HistogramO(N)O(N)
Min Max StackO(1)O(N)
Next Greater ElementO(N)O(N)
Previous Greater ElementO(N)O(N)
Stock SpanO(N)O(N)
KmpO(N + M)O(M)
MinimumwindowsubstringO(N + M)O(K)
PalindromecheckO(N)O(1)
PermutationinstringO(N + M)O(K)
RabinkarpO(N + M)O(1)
ZalgorithmO(N + M)O(N + M)
Tree Bfs VariantsO(N)O(W)
Tree Dfs TraversalsO(N)O(H)
Tree Diameter Height DepthO(N)O(H)
Tree Max Path SumO(N)O(H)
Tree Recursion Bottom UpO(N)O(H)
Tree Recursion Top DownO(N)O(H)
Trie BitwiseO(N x 31)O(N x 31)
Trie Insert SearchO(L)O(N x L x 26)
Trie Prefix MatchO(P)O(K x L)

AlgoCrux learning guide

Learn data structures and algorithms with AlgoCrux

Data structures and algorithms, often shortened to DSA, are the tools programmers use to organize information and solve problems efficiently. An array gives fast access by index; a hash table supports average-case key lookup; a queue processes items in arrival order; and a graph represents relationships between objects. Algorithms define the steps that operate on these structures. Learning both together helps you understand not only how to make a program work, but also why one approach can be faster, clearer, or more suitable than another.

Why visualize an algorithm?

Reading code is important, but it can be difficult to picture how pointers, indices, recursive calls, or graph frontiers change from one line to the next. AlgoCrux is an interactive DSA learning site built to make those state changes easier to inspect. Its algorithm animations show operations step by step, so learners can pause, move through an execution, and connect an operation to the data it changes. Use a visualization to form a mental model, then explain the same process in your own words and implement it without relying on the animation.

The gallery covers common ideas such as sorting, searching, array techniques, linked lists, stacks, queues, trees, graphs, recursion, and tries. A visual trace is a learning aid, not a substitute for practice: try predicting the next state before advancing, and pay attention to the invariant that stays true throughout the algorithm.

Build DSA understanding one pattern at a time

Start with fundamentals and learn to recognize recurring patterns. In binary search, define the search interval and the condition that lets you discard half of it. In two-pointer problems, understand what pointer movement proves about the candidates you skip. A sliding window updates information as its boundaries move. A stack is useful when the newest unresolved item should be handled first, while breadth-first search uses a queue to visit a graph or tree level by level. In dynamic programming, identify the smaller states that combine into a larger answer. For recursion and backtracking, decide what a function represents, when a choice should be undone, and which branches can be pruned.

Complexity analysis gives a way to compare solutions as input grows. Big-O notation describes an upper growth rate, such as O(n) for a linear scan or O(n log n) for many efficient comparison sorts. Also account for extra memory, repeated work, input constraints, and practical edge cases. AlgoCrux includes complexity references and visual walkthroughs to help connect these trade-offs to actual operations.

Practice, review, and plan with AlgoCrux

Effective coding interview preparation combines learning, retrieval, and review. After studying a pattern, solve a related problem, test boundary cases, and revisit it later. The DSA learning paths help organize concepts; the DSA quiz lets you check topic and subtopic understanding; and the DSA Sheet Planner helps track questions from a study sheet. You can also explore pattern relationships, company-focused practice, and the study schedule to structure your routine.

When you practice, focus on the reasoning behind a solution rather than memorizing code. State the input assumptions, choose a data structure that supports the operations you need, write down the invariant or recurrence, and check small examples by hand. Then consider empty input, duplicate values, one-element cases, large bounds, and cases where no answer exists. This process builds transferable problem-solving skills for coursework, interviews, and software development.

Who can use this DSA visualizer?

AlgoCrux is designed for students learning data structures for the first time, self-taught developers refreshing algorithms, and interview candidates who want a more visual way to review. You can browse a concept, watch an animation, read an implementation, and continue into practice tools at your own pace. Use the site alongside a textbook, class, or problem set: pause when a step is unclear, trace it manually, and return to code once the underlying idea makes sense.

What is AlgoCrux?

AlgoCrux is a DSA learning and practice website centered on interactive algorithm visualizations, concept guides, quizzes, and study planning. It is intended to help make abstract operations easier to follow and to support deliberate practice across core computer science topics.

Ready to see it in motion?

Pick any animation above and step through it frame by frame, at your own pace.

Choose a learning path