Skip to content

Bug Report for hand-of-straights #4033

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
Alishahryar1 opened this issue Apr 11, 2025 · 0 comments
Open

Bug Report for hand-of-straights #4033

Alishahryar1 opened this issue Apr 11, 2025 · 0 comments

Comments

@Alishahryar1
Copy link

Alishahryar1 commented Apr 11, 2025

Bug Report for https://neetcode.io/problems/hand-of-straights

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

This solution gets accepted when it shouldn't:

class Solution:
    def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:
        if len(hand) % groupSize != 0:
            return False
        counts = Counter(hand)
        groups = 0
        for num in hand:
            i = 0
            while i < groupSize and counts[num + i]:
                i += 1
            if i == groupSize:
                groups += 1
                for new_num in range(num, num + i):
                    counts[new_num] -= 1
        return groups == len(hand)//groupSize 

how ever this solution does not begin forming groups with the smallest number therefore it should fail and it does fail for this test case which is not included: hand = [8,8,9,7,7,7,6,7,10,6], groupSize = 2

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