Given an input array of integers, find the length of the longest subarray without reapeating integers.
Example
Input: nums = [2, 5, 6, 2, 3, 1, 5, 6]
Output: 5
Explanation: [5, 6, 2, 3, 1] or [6, 2, 3, 1, 5] are both valid and of maximum length 5
Note:
For this lesson, your algorithm should run in O(n) time and use O(n) extra space
Walkthroughs of the solution. Try the steps first, then watch to compare approaches.
Solution #4 · O(n)
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check