Persistent Systems Coding Assessment 2025-November | HashSets & Sequences | Longest Consecutive Sequence
Question · Posted Jun 2026
Question: Longest Consecutive Sequence Problem Statement Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. Input Format The first line contains T - the number of test cases. For each testcase, the first line contains N. The second line contains N space-separated integers. Output Format For each test case, print the length of the longest consecutive sequence on a new line. Constraints 1 ...
The full answer & interview discussion are available to premium members.
Log in Create a free account