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 22737fd commit 9cfd4edCopy full SHA for 9cfd4ed
example/0.ArraysHash/0128.js
@@ -14,23 +14,7 @@
14
* @return {number}
15
*/
16
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;
+
34
};
35
36
0 commit comments