Advertisement
smj007

Untitled

Aug 2nd, 2023
1,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. class Solution:
  2.     def maxArea(self, height: List[int]) -> int:
  3.  
  4.         left = 0
  5.         right = len(height) - 1
  6.         res = 0
  7.  
  8.         while(left < right):
  9.             area = (right - left)*min(height[left], height[right])
  10.             res = max(area, res)
  11.            
  12.             if (height[left]<=height[right]):
  13.                 left = left + 1
  14.             else:
  15.                 right = right - 1
  16.  
  17.         return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement