Skip to content

Commit 9cfd4ed

Browse files
BarklimBarklim
Barklim
authored and
Barklim
committed
Update 0128.js
1 parent 22737fd commit 9cfd4ed

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

example/0.ArraysHash/0128.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,7 @@
1414
* @return {number}
1515
*/
1616
var longestConsecutive = function(nums) {
17-
const set = new Set(nums);
18-
let result = 0;
19-
20-
for (const num of set) {
21-
if (!set.has(num - 1)) {
22-
let count = 1;
23-
let n = num;
24-
25-
while (set.has(n + 1)) {
26-
n++;
27-
count++;
28-
}
29-
result = Math.max(result, count);
30-
}
31-
}
32-
33-
return result;
17+
3418
};
3519

3620

0 commit comments

Comments
 (0)