Beats 87% of the java solution


  • 0

    class Solution {
    public int maxArea(int[] height) {
    int left=0;
    int right=height.length-1;
    int maxarea=0;
    int newarea;
    while(right>left)
    {
    newarea=(height[left]<height[right]?height[left]:height[right])*(right-left);
    maxarea=maxarea>newarea?maxarea:newarea;
    if(height[left]>height[right])
    right--;
    else left++;
    }

        return maxarea;
       
    }
    

    }


Log in to reply
 

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