simple java solution


  • 0
    S
    public class Solution {
        public int maxArea(int[] height) {
           int l = 0;
           int r = height.length-1;
           int mmax = 0;
           while(l<r){
               
            if(height[l]<height[r]){
                
                mmax = Math.max(mmax,(r-l)*height[l]);
                l++;
            }else {
               mmax = Math.max(mmax,(r-l)*height[r]);
                r--;
            }
           }
            return mmax;
        }
    }
    

Log in to reply
 

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