In this video we will see how to find the length of the longest sub-sequence from a given array, such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order.
Example:
Input: arr[] = {1, 9, 3, 10, 4, 20, 2}
Output: 4
Explanation:
The subsequence 1, 3, 4, 2 is the longest
subsequence of consecutive elements
Check out the video to see how we implement this!!
Practice Problem: https://practice.geeksforgeeks.org/problems/longest-consecutive-subsequence2449/1
Article: https://www.geeksforgeeks.org/longest-consecutive-subsequence/
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/