Skip to content

Bug Report for anagram-groups #4052

Closed
Closed
@jungeun122333

Description

@jungeun122333

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions