Question bank › Hashing
Dsa Hashing Medium

Subarray with Unique Elements

Given an integer array, find the length of the longest subarray that has all unique elements. A subarray is a contiguous section of the array. Input: A single line containing space-separated integers. Output: An integer representing the length of the longest subarray with all unique elements. Example: Input: 1 2 3 2 4 Output: 3 (This corresponds to the subarray [2, 4] or [3, 2, 4] which are longest with unique elements)

Key concepts

hashingarrayssubarrays

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.