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 d6fc961 commit ddb36b6Copy full SHA for ddb36b6
longest-consecutive-sequence/tolluset.ts
@@ -6,12 +6,8 @@ function longestConsecutive(nums: number[]): number {
6
const consecutives = [...new Set(nums.sort((a, b) => b - a))];
7
const n = consecutives.length;
8
9
- if (n === 0) {
10
- return 0;
11
- }
12
-
13
- if (n === 1) {
14
- return 1;
+ if (n <= 1) {
+ return n;
15
}
16
17
const bucket = [...Array(n)].map((): Set<number> => new Set());
0 commit comments