#C6337. Smallest Substring Containing All Distinct Characters

    ID: 50086 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 smallest substring of s which contains every distinct character present in s.

Let \(D\) be the set of all distinct characters in \(s\). You need to find a substring such that for every character \(d \in D\), \(d\) appears in that substring. If there are multiple substrings with the minimum length, the one found by the standard sliding window approach is expected.

The input is provided via stdin and the output should be printed to stdout.

inputFormat

A single line containing a non-empty string s.

outputFormat

Print the smallest substring of s that contains all distinct characters of s.## sample

aabcbcdbca
dbca