Fetching algorithms...
Fetching algorithms...
Watch key transitions, pointers, and variables update step-by-step.
Read clean, documented implementations across multiple patterns.
Sketch diagrams on an infinite canvas and draft notes directly inline.
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