Longest consecutive subsequence
Given an array of positive integers. Find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order.
- Time : O(n)
- Space : O(n)
c++
1 | class Solution { |