Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug Report for hand-of-straights #4033

Closed
@Alishahryar1

Description

@Alishahryar1

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

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp