javascript simple solution with explanation
The idea is to put all the elements in the set and than again loop throuh the array and check that if any element is starting i.e if that element lower value is
***The idea is to put all the elements in the set and than again loop throuh the array and check that if any element is starting i.e if that element lower value is not in the set, than run a loop untill that elemnt next value is in the set. and maintain the count ata the same time***\n    \n\t\n**STEPS**\n*   Initialize a blank set\n*  run a loop over the nums arry and put all the element in the set\n*  again run another loop over nums\n*  check if that current element is starting element of the sequence. we can check that by seeing that if that element previous element is already in the set. if previous element is not in the set, then go inside that condition.\n*  inside take a count as 0\n*  start a loop with the condition that till element next value is present in the set\n*  offcourse increment the element to check for next value inside while condition. and also increment the count\n* maintain a maximum count value during each elemengt iteration\n* at last return that maximum value\n\n\n```\nvar longestConsecutive = function(nums) {\n    \n    let set = new Set()   //initializing a blank set\n    for(let ele of nums){  //loop over nums and put all elements in the set\n        set.add(ele)\n    }\n    let maxCount = 0   //maintain a maximum count value\n    for(let ele of nums){  //again loop over nums array\n        if(!set.has(ele-1)){  //check if a element is a starting element of the sequence\n            let count = 0  //if so, take count as 0\n            while(set.has(ele)){  //start a loop with the condition untill element+1 is present in the set\n                ele++   //making the element as element+1\n                count++  //incrementing the count\n            }\n            maxCount = Math.max(maxCount, count)  //maintaining the maximum count value\n        }\n    }\n    return maxCount\n};
['JavaScript']