We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6e804a3 commit b93d0f5Copy full SHA for b93d0f5
solution/0800-0899/0846.Hand of Straights/Solution.ts
@@ -1,17 +1,17 @@
1
-export function isNStraightHand(hand: number[], groupSize: number) {
2
- const map: Record<number, number> = {};
3
-
+function isNStraightHand(hand: number[], groupSize: number) {
+ const cnt: Record<number, number> = {};
4
for (const i of hand) {
5
- map[i] = (map[i] ?? 0) + 1;
+ cnt[i] = (cnt[i] ?? 0) + 1;
6
}
7
8
- const keys = Object.keys(map).map(Number);
9
+ const keys = Object.keys(cnt).map(Number);
10
for (const i of keys) {
11
- while (map[i]) {
+ while (cnt[i]) {
12
for (let j = i; j < groupSize + i; j++) {
13
- if (!map[j]) return false;
14
- map[j]--;
+ if (!cnt[j]) {
+ return false;
+ }
+ cnt[j]--;
15
16
17
0 commit comments