#K44737. Longest Unique Substring
Longest Unique Substring
Longest Unique Substring
Given a string S
, your task is to determine the length of the longest substring that contains only unique characters. In other words, find the maximum length of a contiguous segment of S
where no character repeats.
This is a classic problem that can be efficiently solved using the sliding window technique in O(n) time complexity, where n is the length of the string. Understanding how to update the window correctly when a repeated character is encountered is key to solving this problem.
inputFormat
The input consists of a single line containing the string S
. Note that S
may contain letters, digits, and special characters, and it can also be empty.
outputFormat
Output a single integer representing the length of the longest substring in S
that does not contain any repeating characters.
abcabcbb
3