- Notifications
You must be signed in to change notification settings - Fork2.4k
Closed
Description
Bug Report forhttps://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
Metadata
Metadata
Assignees
Labels
No labels