Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var maxArea = function(height) {
- var max = 0, left = 0, right = height.length - 1;
- var term, thisArea, width;
- while (left < right) {
- width = right - left;
- if (height[left] < height[right]) {
- thisArea = height[left] * width;
- left++;
- } else {
- thisArea = height[right] * width;
- right--;
- }
- max = max > thisArea ? max : thisArea;
- }
- return max;
- };
Add Comment
Please, Sign In to add comment