2 ms·
Here is a novel solution. make stack water = 0 for n in columns while stack not empty and n > stack top water += min(stack bottom, n) - stack t
by twiceaday 13y ago
Here is a novel solution.
make stack
water = 0
for n in columns
while stack not empty and n > stack top
water += min(stack bottom, n) - stack top
pop stack
stack push n