Longest substring without repeats
Print the length of the longest substring in which no character repeats.
Reported in: Infosys (DSE / SP, 2021–26), Tech Mahindra, LTIMindtree (memory-based)
Input
One line: the string.
Output
The length.
Constraints
1 ≤ length ≤ 10^5.
Example 1
Input:
abcabcbb
Output:
3Example 2
Input:
bbbbb
Output:
1Hint: Sliding window: remember the last index of each character and move the left edge past repeats.