Skip to content

Commit 70614c5

Browse files
authored
Update README.md
1 parent b93d0f5 commit 70614c5

File tree

1 file changed

+9
-9
lines changed
  • solution/0800-0899/0846.Hand of Straights

1 file changed

+9
-9
lines changed

solution/0800-0899/0846.Hand of Straights/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,20 @@ func isNStraightHand(hand []int, groupSize int) bool {
172172
#### TypeScript
173173

174174
```ts
175-
export function isNStraightHand(hand: number[], groupSize: number) {
176-
const map: Record<number, number> = {};
177-
175+
function isNStraightHand(hand: number[], groupSize: number) {
176+
const cnt: Record<number, number> = {};
178177
for (const i of hand) {
179-
map[i] = (map[i] ?? 0) + 1;
178+
cnt[i] = (cnt[i] ?? 0) + 1;
180179
}
181180

182-
const keys = Object.keys(map).map(Number);
183-
181+
const keys = Object.keys(cnt).map(Number);
184182
for (const i of keys) {
185-
while (map[i]) {
183+
while (cnt[i]) {
186184
for (let j = i; j < groupSize + i; j++) {
187-
if (!map[j]) return false;
188-
map[j]--;
185+
if (!cnt[j]) {
186+
return false;
187+
}
188+
cnt[j]--;
189189
}
190190
}
191191
}

0 commit comments

Comments
 (0)