July 31, 2024 |14.0K Views

    Longest consecutive subsequence | SDE Sheet | Hashing

    Description
    Discussion

    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/