JAVA Easy Understand Solution


  • 1
    Y
    public class Solution {
        public int maxArea(int[] height) {
            int left = 0;
            int right = height.length - 1;
            int res = 0;
            while(left < right){
                res = Math.max(res, Math.min(height[right], height[left]) * (right - left));
                if(height[right] < height[left])
                    right--;
                else
                    left++;
            }
            return res;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.