#K50672. Shortest Beautiful Substring
Shortest Beautiful Substring
Shortest Beautiful Substring
You are given a string ( s ) containing only lowercase letters. Your task is to find the length of the shortest substring that is beautiful. A substring is considered beautiful if it contains at least one (a), one (b), and one (c). If no such substring exists, output -1.
For example, if ( s = ) "abcabc", one of the shortest beautiful substrings is "abc" with length 3.
Input is provided via standard input (stdin) and output should be written to standard output (stdout).
inputFormat
The input consists of a single line containing the string ( s ) ((1 \leq |s| \leq 10^5)). The string only contains lowercase English letters.
outputFormat
Output a single integer representing the length of the shortest beautiful substring that contains at least one (a), one (b), and one (c). If no such substring exists, output -1.## sample
abcabc
3
</p>