No.345 Minimum Chihuahua Problem
タグ : / 解いたユーザー数 696
作問者 :
🍡yurahuna
Problem Statement
C loves Chihuahuas. So C decided to find Chihuahuas in strings as well.
According to C, a string is called a "Chihuahua string" if it contains 'c', 'w', 'w' in this order.
Since C likes small Chihuahuas, C wants to find a Chihuahua string whose length is as small as possible.
Given a string $S$, find the minimum length among its contiguous substrings that are Chihuahua strings.
Input
S
The first line contains a string $S (1 \le |S| \le 100)$.
$S$ consists only of lowercase English letters.
Output
Print as an integer the minimum length among the contiguous substrings of $S$ that are Chihuahua strings.
If $S$ does not contain a Chihuahua string, print $-1$.
Print a newline at the end.
Sample
Sample 1
Input
ilovechiwawa
Output
6
Sample 2
Input
wachiwachi
Output
-1
Sample 3
Input
chiwaaaaaaamikawayadeeeeesu
Output
16
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。