Skip to content

Commit ddb36b6

Browse files
committed
refactor: simplify pre validate
1 parent d6fc961 commit ddb36b6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

longest-consecutive-sequence/tolluset.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ function longestConsecutive(nums: number[]): number {
66
const consecutives = [...new Set(nums.sort((a, b) => b - a))];
77
const n = consecutives.length;
88

9-
if (n === 0) {
10-
return 0;
11-
}
12-
13-
if (n === 1) {
14-
return 1;
9+
if (n <= 1) {
10+
return n;
1511
}
1612

1713
const bucket = [...Array(n)].map((): Set<number> => new Set());

0 commit comments

Comments
 (0)