codedive
0110100110
48E138M27H·213 problems
Stop reading about algorithms.
Watch them execute.
The free LeetCode visualizer. Step through 213+ problems line by line — watch arrays, trees, graphs, and DP animate in real time with every variable visible at every step.
Line-by-line executionLive data structure animationsVariable inspectorCustom inputShareable steps⌘K Command paletteDraw & annotate✦ Test yourself
Built this while grinding LeetCode nights and weekends.
If it helped you prep, an upvote means everything ♥
P
Support us onProduct Hunt
▲Upvote
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
08
Tries
2M1H
09
Heap / Priority Queue
2E4M1H
10
Backtracking
7M1H
11
Graphs
11M1H
12
Advanced Graphs
3M3H
13
1-D Dynamic Programming
2E11M
14
2-D Dynamic Programming
5M3H
15
Greedy
8M
16
Intervals
1E3M1H
17
Math & Bit Manipulation
6E5M
18
Other
22E41M8H