Skip to content

Commit b0544ba

Browse files
committed
6-6-24
1 parent d3105cf commit b0544ba

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Jun-6-24.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def isNStraightHand(self, hand: List[int], groupSize: int) -> bool:
3+
if len(hand)%groupSize!=0:
4+
return False
5+
dic = dict(Counter(hand))
6+
minHeap = list(dic.keys())
7+
heapq.heapify(minHeap)
8+
while minHeap:
9+
start = minHeap[0]
10+
for i in range(start,start+groupSize):
11+
if i not in dic.keys():
12+
return False
13+
dic[i] -= 1
14+
if dic[i] == 0:
15+
if i!=minHeap[0]:
16+
return False
17+
heapq.heappop(minHeap)
18+
return True

0 commit comments

Comments
 (0)