java solution


  • 0
    C
    public class Solution {
    public int maxArea(int[] height) {
        if(height.length<=1)return 0;
        
        int j=0;
        int k=height.length-1;
        
        int max = 0;
        
        while(k>j)
        {
            max =max>=(k-j)*min(height[k],height[j])?max:(k-j)*min(height[k],height[j]);
            
            if(height[k]>=height[j])
            {
                j++;
            }
            else
            {
                k--;
            }
        }
        return max;
    }
    
    public int min(int i,int j)
    {
    return i>=j?j:i;
    }
    

    }


Log in to reply
 

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