Skip to content

Commit b93d0f5

Browse files
authored
Update Solution.ts
1 parent 6e804a3 commit b93d0f5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

solution/0800-0899/0846.Hand of Straights/Solution.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
export function isNStraightHand(hand: number[], groupSize: number) {
2-
const map: Record<number, number> = {};
3-
1+
function isNStraightHand(hand: number[], groupSize: number) {
2+
const cnt: Record<number, number> = {};
43
for (const i of hand) {
5-
map[i] = (map[i] ?? 0) + 1;
4+
cnt[i] = (cnt[i] ?? 0) + 1;
65
}
76

8-
const keys = Object.keys(map).map(Number);
9-
7+
const keys = Object.keys(cnt).map(Number);
108
for (const i of keys) {
11-
while (map[i]) {
9+
while (cnt[i]) {
1210
for (let j = i; j < groupSize + i; j++) {
13-
if (!map[j]) return false;
14-
map[j]--;
11+
if (!cnt[j]) {
12+
return false;
13+
}
14+
cnt[j]--;
1515
}
1616
}
1717
}

0 commit comments

Comments
 (0)