#dsa #javascript
Solution: https://github.com/therajatg/DSA/blob/main/008-longest-consecutive-sequence.js
Given an array of integers, return the length of the longest consecutive sequence of elements that can be formed.
A consecutive sequence is a sequence of elements in which each element is exactly 1 greater than the previous element. The elements do not have to be consecutive in the original array.
You must write an algorithm that runs in O(n) time.
// Input: nums = [20,2,4,10,3,4,5]
// Output: 4
Download
0 formats
No download links available.
DSA Problem 008: Longest Consecutive Sequence | NatokHD