File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
solution/0800-0899/0846.Hand of Straights Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -314,7 +314,9 @@ func isNStraightHand(hand []int, groupSize int) bool {
314
314
``` ts
315
315
function isNStraightHand(hand : number [], groupSize : number ): boolean {
316
316
const n = hand .length ;
317
- if (n % groupSize ) return false ;
317
+ if (n % groupSize ) {
318
+ return false ;
319
+ }
318
320
319
321
const groups: number [][] = Array .from ({ length: n / groupSize }, () => []);
320
322
hand .sort ((a , b ) => a - b );
@@ -323,14 +325,18 @@ function isNStraightHand(hand: number[], groupSize: number): boolean {
323
325
let isPushed = false ;
324
326
325
327
for (const g of groups ) {
326
- if (g .length === groupSize || (g .length && hand [i ] - g .at (- 1 )! !== 1 )) continue ;
328
+ if (g .length === groupSize || (g .length && hand [i ] - g .at (- 1 )! !== 1 )) {
329
+ continue ;
330
+ }
327
331
328
332
g .push (hand [i ]);
329
333
isPushed = true ;
330
334
break ;
331
335
}
332
336
333
- if (! isPushed ) return false ;
337
+ if (! isPushed ) {
338
+ return false ;
339
+ }
334
340
}
335
341
336
342
return true ;
You can’t perform that action at this time.
0 commit comments