Problem Statement
Pikachu is a well-known character in the Pokemon anime series.
Pikachu can speak, but only 3 syllables: "pi", "ka", and "chu".
Therefore Pikachu can only pronounce strings that can be created as a concatenation of one or more syllables he can pronounce. For example, he can pronounce the words "pikapi" and "pikachu".
You are given a String word. Your task is to check whether Pikachu can pronounce the string. If the string can be produced by concatenating copies of the strings "pi", "ka", and "chu", return "YES" (quotes for clarity). Otherwise, return "NO".
You are given a String word. Your task is to check whether Pikachu can pronounce the string. If the string can be produced by concatenating copies of the strings "pi", "ka", and "chu", return "YES" (quotes for clarity). Otherwise, return "NO".
Definition
- Class:
- PikachuEasy
- Method:
- check
- Parameters:
- String
- Returns:
- String
- Method signature:
- String check(String word)
- (be sure your method is public)
Constraints
- word will contain between 1 and 50 characters, inclusive.
- Each character of word will be a lowercase letter ('a'-'z').
Examples
"pikapi"
Returns: "YES"
"pikapi" = "pi" + "ka" + "pi", so Pikachu can say it."pipikachu"
Returns: "YES"
This time we have "pipikachu" = "pi" + "pi" + "ka" + "chu", so Pikachu can say it as well."pikaqiu"
Returns: "NO"
Pikachu can't say "pikaqiu" since 'q' does not appear in "pi", "ka", or "chu"."topcoder"
Returns: "NO"
"piika"
Returns: "NO"
"chupikachupipichu"
Returns: "YES"
"pikapipachu"
Returns: "NO"