MediumTopic: Sliding WindowExpected: O(N) Time • O(min(N, M)) Space
Longest Window of Unique Characters
Given a string `s`, find the length of the longest contiguous window that contains no repeated characters.
Examples
Input: s = "dvdf"
Output: 3
The longest repeat-free window is "vdf", length 3.
Input: s = "aaaa"
Output: 1
Every window longer than 1 character repeats.
Constraints
- 0 <= s.length <= 4 * 10^4
- s may contain letters, digits, symbols, and spaces.
solution.js
JavaScript (ES6+)Test Execution Results
Input:
["dvdf"]Expected:
3Your Output:
--