Practice
Learn
← Quit
0 / 0 correct
Algorithms
Hard
1 of 40
What is the key insight in 'trapping rain water' in O(n) time and O(1) space?
A
Sort heights
B
Two pointers: water at a position is bounded by the smaller of the max heights on each side; move the side with the smaller max
C
Use a heap of all heights
D
Recursion on halves