Closed
Description
Bug Report for https://neetcode.io/problems/anagram-groups
https://neetcode.io/problems/max-water-container
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.?title=Bug Report for top-k-elements-in-list
The given two pointers solution doesn't work when heights = [3,1,1,1,1,1,1,7,1,3]
. We should handle it separately when the heights are the same.
class Solution:
def maxArea(self, heights: List[int]) -> int:
l, r = 0, len(heights) - 1
res = 0
while l < r:
area = min(heights[l], heights[r]) * (r - l)
res = max(res, area)
if heights[l] <= heights[r]:
l += 1
else:
r -= 1
return res
Metadata
Metadata
Assignees
Labels
No labels