# code tpl Input: height = [1,8,6,2,5,4,8,3,7] Output: 49 1. two from left and right 2. if h (left) > h(right), move right, for this right because max(right*distance(right - left)) this right pos 4. l1 l2 l3 ... r*, (l1, r) > (l2, r) > (l3, r) #[] = 0 #[3] = 0 #[1 9] min(1, 9)*(1-0) = 1*1 ```python= def maxArea(self, height: List[int]) -> int: left = 0 right = len(height) - 1 ans = 0 while left < right: area = min(height[left], height[right])*(right-left) ans = max(ans, area) if height[left] > height[right]: right -= 1 else: left += 1 return ans # N : length of height # TC O(N) ``` ###### tags: `mock interview` `面試`