Round 1
Questions: Find the longest pair in a given list of integers such that all numbers within the pair (inclusive) are contained in the input.
Example:
Input -> [3,8,9,2,5,7,4]
Output -> 2,5
Explanation -> All integers within the range 2 and 5 (inclusive), i.e., 2, 3, 4 and 5 are present in the array. The other ranges (e.g., [7, 9]) are smaller.
Constraints: None specified. Duplicates allowed.
Candidate's Approach
Utilised a hashset to keep track of encountered integers and to skip duplicates. For each newly encountered integer in the array, check the number of integers greater than this integer and the number of integers smaller than this integer in the set. Keep track of the longest such range encountered and remove each processed integer from the set.
Interviewer's Feedback
No feedback provided.