#K8511. Shortest Unique Substring Length
Shortest Unique Substring Length
Shortest Unique Substring Length
Given a string ( S ), your task is to find the length of the shortest contiguous substring that contains all the unique characters present in ( S ).
Formally, let ( U ) be the set of unique characters of ( S ). You need to determine the minimum length ( L ) such that there exists a substring ( S[i \ldots j] ) (with ( 0 \leq i \leq j < |S| )) that contains every character in ( U ) at least once.
For example, if ( S = \texttt{abcabcbb} ), the set ( U = {a, b, c} ), and the shortest substring that contains ( U ) is ( \texttt{abc} ) which has length 3.
inputFormat
The input consists of a single line containing the string ( S ). The string may include both lowercase and uppercase letters and can be empty.
outputFormat
Output a single integer representing the length of the shortest substring of ( S ) that contains all unique characters of ( S ).## sample
abcabcbb
3