Question bank › Arrays
Dsa Arrays Hard

Longest Subarray of Unique Elements

Given an array of integers, find the length of the longest subarray that contains only unique elements. A subarray is a contiguous part of the array. Return the length of this longest subarray. Input format: - The first line contains an integer n (1 ≤ n ≤ 10^5) - the size of the array. - The second line contains n space-separated integers a[i] (0 ≤ a[i] ≤ 10^9). Output format: - A single integer - the length of the longest subarray with unique elements. Example: Input: 8 1 2 3 2 4 5 1 6 Output: 5

Key concepts

arrayshashmapsliding window

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.