codedive
0110100110
48E132M27H·207 problems
Stop reading about algorithms.
Watch them execute.
Step through 207+ LeetCode problems line by line. Watch arrays, trees, and graphs animate in real time — with every variable visible at every step.
Line-by-line executionLive data structure animationsVariable inspectorCustom inputShareable steps
codedive/Trapping Rain Water·hard
1 / 24
Initialize pointers: l=0, r=11. leftMax=0, rightMax=1
1def trap(height: List[int]) -> int:2 if not height: return 03 l, r = 0, len(height) - 14 leftMax, rightMax = height[l], height[r]5 res = 067 while l < r:8 if leftMax < rightMax:9 l += 110 leftMax = max(leftMax, height[l])11 res += leftMax - height[l]12 else:13 r -= 114 rightMax = max(rightMax, height[r])15 res += rightMax - height[r]16 return res
Left Max0
Total Water
0units
Right Max1
01
Arrays & Hashing
3E9M
02
Two Pointers
1E3M1H
03
Sliding Window
3M2H
04
Stack
1E5M1H
05
Binary Search
1E5M1H
06
Linked List
3E6M2H
07
Trees
6E7M1H
226Invert Binary TreeE104Maximum Depth of Binary TreeE543543. Diameter of Binary TreeE100Same TreeE572Subtree of Another TreeE110Balanced Binary TreeE102Binary Tree Level Order TraversalM199Binary Tree Right Side ViewM1448Count Good Nodes in Binary TreeM98Validate Binary Search TreeM230Kth Smallest Element in a BSTM235Lowest Common Ancestor of a Binary Search TreeM105Construct Binary Tree from Preorder and Inorder TraversalM124Binary Tree Maximum Path SumH
08
Tries
2M1H
09
Heap / Priority Queue
2E4M1H
10
Backtracking
7M1H
11
Graphs
11M1H
12
Advanced Graphs
3M3H
13
1-D Dynamic Programming
2E11M
746Min Cost Climbing StairsE121Best Time to Buy and Sell StockE198House RobberM213House Robber IIM5Longest Palindromic SubstringM647Palindromic SubstringsM91Decode WaysM322Coin ChangeM152Maximum Product SubarrayM139Word BreakM416Partition Equal Subset SumM494Target SumM300Longest Increasing SubsequenceM
14
2-D Dynamic Programming
5M3H
15
Greedy
8M
16
Intervals
1E3M1H
17
Math & Bit Manipulation
6E5M
18
Other
22E35M8H
67Add BinaryE637Average of Levels in Binary TreeE224Basic CalculatorH122Best Time to Buy and Sell Stock IIM123Best Time to Buy and Sell Stock IIIH188Best Time to Buy and Sell Stock IVH173Binary Search Tree IteratorM103Binary Tree Zigzag Level Order TraversalM201Bitwise AND of Numbers RangeM135CandyH70Climbing StairsE77CombinationsM323Number of Connected ComponentsM106Construct Binary Tree from Inorder and Postorder TraversalM427Construct Quad TreeM219Contains Duplicate IIE108Convert Sorted Array to Binary Search TreeE222Count Complete Tree NodesE399Evaluate DivisionM172Factorial Trailing ZeroesM373Find K Pairs with Smallest SumsM114Flatten Binary Tree to Linked ListM289Game of LifeM274H-IndexM380Insert Delete GetRandom O(1)M57Insert IntervalM12Integer to RomanM502IPOH392Is SubsequenceE205Isomorphic StringsE58Length of Last WordE14Longest Common PrefixE329Longest Increasing PathH236Lowest Common Ancestor of a Binary TreeM169Majority ElementE149Max Points on a LineH221Maximal SquareM88Merge Sorted ArrayE452Minimum Number of Arrows to Burst BalloonsM64Minimum Path SumM209Minimum Size Subarray SumM9Palindrome NumberE86Partition ListM66Plus OneE383Ransom NoteE26Remove Duplicates from Sorted ArrayE80Remove Duplicates from Sorted Array IIM82Remove Duplicates from Sorted List IIM27Remove ElementE92Reverse Linked List IIM151Reverse Words in a StringM13Roman to IntegerE189Rotate ArrayM61Rotate ListM71Simplify PathM137Single Number IIM69Sqrt(x)E309Stock with CooldownM30Substring with Concatenation of All WordsH228Summary RangesE101Symmetric TreeE120TriangleM63Unique Paths IIM290Word PatternE6Zigzag ConversionM