No.1159 Sashiming String
Problem Statement
For an English-letter string $S$, we say that $S$ is a Sashiming string if the $1$st character of $S$ is an uppercase S and the last $3$ characters are ing.
For example, Snapping and String are Sashiming strings, but sashiming and SAMPLING are not Sashiming strings.
Given an English-letter string $S$, find the number of non-empty contiguous substrings of $S$ that are Sashiming strings.
Even if some of them are equal as strings, those with different starting positions are counted separately.
Input
$S $
$1 \leq |S| \leq 2 \times 10^5$
$S$ consists of uppercase and lowercase English letters.
Output
Output the answer on $1$ line.
Print a newline at the end.
Sample
Sample 1
Input
SingingSashiming
Output
4
Among the non-empty contiguous substrings of SingingSashiming, those that are Sashiming strings are the $4$ strings Sing, Singing, Sashiming, and SingingSashiming, so output $4$.
Sample 2
Input
SomethingISNOTSashiming
Output
4
Something and Sashiming are similar.
Source
Nada High School 75th Class Junior High Graduation Commemorative Contest: Sashiming String
writer: Sashiming
tester: Mitarushi
Ported in accordance with HackerRank's terms of service. Some parts have been modified.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂