Skip to content

Bug Report for anagram-groups #4052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jungeun122333 opened this issue Apr 17, 2025 · 0 comments
Open

Bug Report for anagram-groups #4052

jungeun122333 opened this issue Apr 17, 2025 · 0 comments

Comments

@jungeun122333
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant