text function maxArea(height): left = 0 right = length(height) - 1 maxArea = 0 while left < right: width = right - left h = min(height[left], height[right]) area = width * h maxArea = max(maxArea, area) if height[left] < height[right]: left++ else: right-- return maxArea Time complexity: . Each pointer moves at most times. Space complexity: . Just two pointers.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/two-pointers-sliding-window/container-with-most-water-pseudocode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████████████████████████████████████████████████████████████████████████████████████████████████████████