Problem Statement
Given an unsorted array of integers nums, find the length of the longest sequence of consecutive elements.
A consecutive sequence consists of numbers that follow each other in increasing order without gaps (e.g., [1, 2, 3, 4]).
Return the length of the longest consecutive elements sequence.
Example
Input: nums = [100, 4, 200, 1, 3, 2]
Output: 4
Explanation: The longest consecutive sequence is [1, 2, 3, 4].
Constraints
- 0 <= nums.length <= 10⁵
- -10⁹ <= nums[i] <= 10⁹
Expected Solution
Implement an optimized C++ solution with:
- Time Complexity: O(n)
- Space Complexity: O(n)
- Using an unordered_set or similar hashing technique.
Hey @SilvaneUX i would like to ressolve this issue... I am resolving and creating pull request... Hoping for your merge and kindly add "Hacktoberfest" Tag as well..
Thank you...
Problem Statement
Given an unsorted array of integers
nums, find the length of the longest sequence of consecutive elements.A consecutive sequence consists of numbers that follow each other in increasing order without gaps (e.g., [1, 2, 3, 4]).
Return the length of the longest consecutive elements sequence.
Example
Input: nums = [100, 4, 200, 1, 3, 2]
Output: 4
Explanation: The longest consecutive sequence is [1, 2, 3, 4].
Constraints
Expected Solution
Implement an optimized C++ solution with:
Hey @SilvaneUX i would like to ressolve this issue... I am resolving and creating pull request... Hoping for your merge and kindly add "Hacktoberfest" Tag as well..
Thank you...