Dsa
Sliding Window
Medium
Maximum Unique Subarray
Given an array of integers, find the maximum sum of a subarray that contains all unique elements. If the array is empty, return 0.
Input:
- A single line containing n (1 <= n <= 100,000) integers.
Output:
- Print the maximum sum of subarrays with unique elements.
Example:
Input:
4 5 6 4 2 5 1
Output:
18
Key concepts
sliding_windowarrayhash_map
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