JavaScript
\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar longestConsecutive = function(nums) {\n    let set = new Set();\n    for(const n of nums) {\n   
```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar longestConsecutive = function(nums) {\n    let set = new Set();\n    for(const n of nums) {\n        set.add(n);\n    }\n    let max = 0;\n    for(let n of set) {\n        if(!set.has(n-1)) {\n            let count = 0;\n            while(set.has(n++)) {\n                count++;\n            }\n            max = Math.max(count, max);\n        }\n    }\n    return max;\n};\n```
['Ordered Set', 'JavaScript']