Skip to content

Commit c8025fa

Browse files
authored
Update Solution2.ts
1 parent 4e56d96 commit c8025fa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
function isNStraightHand(hand: number[], groupSize: number): boolean {
22
const n = hand.length;
3-
if (n % groupSize) return false;
3+
if (n % groupSize) {
4+
return false;
5+
}
46

57
const groups: number[][] = Array.from({ length: n / groupSize }, () => []);
68
hand.sort((a, b) => a - b);
@@ -9,14 +11,18 @@ function isNStraightHand(hand: number[], groupSize: number): boolean {
911
let isPushed = false;
1012

1113
for (const g of groups) {
12-
if (g.length === groupSize || (g.length && hand[i] - g.at(-1)! !== 1)) continue;
14+
if (g.length === groupSize || (g.length && hand[i] - g.at(-1)! !== 1)) {
15+
continue;
16+
}
1317

1418
g.push(hand[i]);
1519
isPushed = true;
1620
break;
1721
}
1822

19-
if (!isPushed) return false;
23+
if (!isPushed) {
24+
return false;
25+
}
2026
}
2127

2228
return true;

0 commit comments

Comments
 (0)