Example 1
Input
aabcbcdbca
Output
4
Distinct characters are {a,b,c,d}. Smallest window that contains them all is "dbca" with length 4.
Full lesson preview
Given a string, find the length of the smallest substring that contains all distinct characters present in the original string.
Problem statement
Task
Examples
Input
aabcbcdbca
Output
4
Distinct characters are {a,b,c,d}. Smallest window that contains them all is "dbca" with length 4.
Input format
Output format
Constraints
Samples
Input
aabcbcdbca
Output
4
Distinct characters are {a,b,c,d}. Smallest window length containing them all is 4.