#K64027. Smallest Substring Containing All Distinct Characters

    ID: 31884 Type: Default 1000ms 256MiB

Smallest Substring Containing All Distinct Characters

Smallest Substring Containing All Distinct Characters

You are given a string s. Your task is to find the length of the smallest substring of s that contains all the distinct characters present in s.

For example, consider the string "aabcbcdbca". The distinct characters in the string are \(a, b, c, d\). The smallest substring that contains all these characters is "dbca" which has length 4.

Solve this efficiently using the sliding window technique.

inputFormat

The input consists of a single line that contains the string s. The string can contain any printable characters.

outputFormat

Output a single integer representing the length of the smallest substring of s that contains all the distinct characters present in the original string.

## sample
aabcbcdbca
4