Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 662 |

@arpitsatnalika | 629 |

@code_it_ | 591 |

@prakharxyz | 583 |

@tujhekya | 542 |

@Rahul Jadhav 1 | 458 |

@sivanandh03 | 448 |

@satyam0460 | 429 |

@iamronak | 424 |

@imnm | 424 |

@18eumc107 | 421 |

Complete Leaderboard |

Given an array **A** of integers. Find the length of the longest sub-sequence such that elements in the sub-sequence are consecutive integers, the consecutive numbers can be in any order.

**Example 1:**

Input:7 1 9 3 10 4 20 2Output:4Explanation:Logest consecutive subsequence is 1, 2, 3, 4 of length 4.

**Example 2:**

**Input:**
11
36 41 56 35 44 33 34 92 43 32 42
**Output:**
5

**Your task:**

Complete **findLongestConseqSubseq() **function which takes both the given array and their size as function arguments and returns the length of the longest sub-sequence such that elements in the sub-sequence are consecutive integers.

**Expected Time Complexity **: O(N)

**Expected Auxilliary Space** : O(N)

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{6}

1 <= A_{i }<= 10^{8 }

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Longest Consecutive Subsequence

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.