Longest distinct subarray
HardGiven an array of numbers, write a function that returns the indices of the longest subarray with unique elements.
For example, given the array:
[4, 9, 9, 3, 4, 7]
Your function's output should return the tuple
(2, 5)
since the subarray between those indices: [9, 3, 4, 7]
is the longest one with distinct entries.Note that if there are multiple subarrays with the same length, return the indices of the first subarray found.
Try it first
Solution
6 Essential Hash Tables Coding Interview Problems
Master Hash Tables by trying the coding challenges below.
- 1.Two sumEasy
- 2.Palindrome CheckEasy
- 3.Cover SetMedium
- 4.Missing numberMedium
- 5.Crypto ExchangeMedium
- 6.Distinct SubarrayHard