Interactive visualizations of common algorithms used in LeetCode problems.
Repeatedly swap adjacent out-of-order elements.
O(n²)StableInsert each element into its correct position. Fast for nearly sorted.
O(n²)StableFind minimum, swap to front each pass.
O(n²)Divide-and-conquer: split, sort, merge.
O(n log n)StablePartition around pivot, recurse on halves.
O(n log n) avgIn-placeBuild max-heap, extract max repeatedly. LC 215, 347.
O(n log n)In-placeDistribute into buckets, sort each, concatenate. LC 347, 451.
O(n+k) avgScan every element one by one.
O(n)Halve the search space each step on sorted data. LC 704, 33, 153.
O(log n)Level-by-level exploration using a queue. LC 102, 200, 994.
O(V+E)Shortest PathExplore as deep as possible, then backtrack. LC 200, 695, 79.
O(V+E)StackExpand from S and E simultaneously; meet in the middle. LC 127, 433, 752.
O(b^(d/2))FasterEnqueue all sources at t=0; spread like ripples. LC 994, 542, 1162.
O(V+E)Multi-startDFS all paths S→E; undo visited on backtrack. LC 79, 980, 1219.
O(4^V)All pathsShortest paths in weighted graphs (non-negative). LC 743, 1631.
O((V+E) log V)Min-HeapShortest paths with negative weights. Detects negative cycles. LC 787.
O(V·E)All-pairs shortest paths via intermediate vertices. LC 2642.
O(V³)Find ordering in a DAG (Kahn's BFS). LC 207, 210, 269.
O(V+E)Track connected components with path compression. LC 200, 547, 684.
O(α(n))Converge left & right on sorted array to find target sum. LC 167, 15, 11.
O(n)SortedFixed-size window slides to find max sum subarray. LC 643, 209, 3, 76.
O(n)O(1) range-sum queries after O(n) build. LC 303, 304, 560, 523.
O(1) queryMaximum subarray sum in one pass. LC 53, 152, 918.
O(n)O(1) range updates, prefix-sum to build result. LC 370, 1109.
O(n)Knuth-Morris-Pratt: failure function skips redundant comparisons. LC 28, 214, 1392.
O(n+m)Failure fnRabin-Karp: slide a window, update hash in O(1). Detect substring matches by hash. LC 28, 187, 1044.
O(n+m) avgRabin-KarpBuild dp[i] from dp[i-1], dp[i-2]. Climbing Stairs, House Robber, Fibonacci. LC 70, 198, 509.
O(n)TabulationTake or skip each item. Fill 2D table row-by-row from prior row. LC 416, 494, 1049.
O(n·W)Take/SkipFill a grid cell-by-cell. Unique Paths, Min Path Sum, LCS. LC 62, 64, 1143.
O(m·n)GridEdit Distance (insert/delete/replace) & Longest Palindromic Subsequence. LC 72, 5, 516.
O(m·n)Edit / LPSPost-order DFS; each node carries a dp tuple (rob/skip, gain, depth). LC 337, 124, 543.
O(n)Post-orderInorder / Preorder / Postorder / Level-order with visit numbering. LC 94, 144, 145, 102.
O(n)DFS / BFSPost-order DFS: bubble p/q up; first node holding both is LCA. LC 236, 235, 1123.
O(n)Post-order