class Solution:
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
self.QSort(height,0,len(height)-1)
return height[len(height)-2]*height[len(height)-2]
def QSort(self,height,low,high):
if low<high:
pivot = self.Partition(height,low,high)
self.QSort(height,low,pivot-1)
self.QSort(height,pivot+1,high)
def Partition(self,height,low,high):
pivotkey=height[low]
while low<high:
while(low<high and height[high] >=pivotkey):
high = high-1
height[low]=height[high]
while(low<high and height[low] <=pivotkey):
low = low +1
height[high]=height[low]
height[low]=pivotkey
return low
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
self.QSort(height,0,len(height)-1)
return height[len(height)-2]*height[len(height)-2]
def QSort(self,height,low,high):
if low<high:
pivot = self.Partition(height,low,high)
self.QSort(height,low,pivot-1)
self.QSort(height,pivot+1,high)
def Partition(self,height,low,high):
pivotkey=height[low]
while low<high:
while(low<high and height[high] >=pivotkey):
high = high-1
height[low]=height[high]
while(low<high and height[low] <=pivotkey):
low = low +1
height[high]=height[low]
height[low]=pivotkey
return low