Skip to content

Latest commit

 

History

History
22 lines (21 loc) · 313 Bytes

11.md

File metadata and controls

22 lines (21 loc) · 313 Bytes
func maxArea(height []int) int {
	maxV := 0
	l, r := 0, len(height)-1
	for l < r {
		curHeight := height[l]
		curWidth := r - l
		if height[l] > height[r] {
			curHeight = height[r]
			r--
		} else {
			l++
		}

		curV := curWidth * curHeight
		if curV > maxV {
			maxV = curV
		}
	}
	return maxV
}