Fetching algorithms...
Fetching algorithms...
height = [1,8,6,2,5,4,8,3,7]49[1,1]1Two pointers from both ends. Area is determined by min(height[left], height[right]) × width. Always move the pointer with smaller height inward, as moving the taller one can only decrease area. This greedy approach finds the maximum in O(n) time.
Time Complexity
Space Complexity