Complete the code to initialize the variable that stores the total trapped water.
totalWater := [1]We start counting trapped water from zero, so initializing totalWater to 0 is correct.
Complete the code to update the left maximum height while iterating from the left.
if height[i] > [1] { leftMax = height[i] }
We compare the current height with the left maximum height to update it.
Fix the error in the condition to decide which pointer to move.
if leftMax < [1] { left++ } else { right-- }
The decision depends on comparing leftMax and rightMax to move pointers correctly.
Fill both blanks to calculate trapped water at the left pointer.
if height[left] < [1] { totalWater += [2] - height[left] }
Water trapped at left is difference between leftMax and current height[left].
Fill all three blanks to calculate trapped water at the right pointer.
if height[right] < [1] { totalWater += [2] - height[right] } right--
Water trapped at right is difference between rightMax and current height[right].
