Guest User

Untitled

a guest
Jan 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. var maxArea = function(height) {
  2. var max = 0, left = 0, right = height.length - 1;
  3. var term, thisArea, width;
  4. while (left < right) {
  5. width = right - left;
  6. if (height[left] < height[right]) {
  7. thisArea = height[left] * width;
  8. left++;
  9. } else {
  10. thisArea = height[right] * width;
  11. right--;
  12. }
  13. max = max > thisArea ? max : thisArea;
  14. }
  15. return max;
  16. };
Add Comment
Please, Sign In to add comment