BuffaloBuffalo
SRM 723 · 2017-11-17 · by cgy4ever
SRM 723 · 2017-11-17 · by cgy4ever · String Parsing
Problem Statement
Problem Statement
Did you know that "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo." is a grammatically correct sentence in American English?
In this problem we call a string good if it satisfies the following constraints:
You are given aString s that consists of spaces and lowercase letters.
Return "Good" if s is a good string.
Otherwise, return "Not good".
(Note that the return value is case-sensitive.)
In this problem we call a string good if it satisfies the following constraints:
- The string contains one or more words.
- Each word in the string is "buffalo".
- Each pair of consecutive words is separated by exactly one space.
- There are no spaces at the beginning of the string.
- There are no spaces at the end of the string.
You are given a
Constraints
- s will contain between 1 and 1,000 characters, inclusive.
- Each character in s will be a lowercase English letter ('a' - 'z') or a space (' ').
Examples
0)
"buffalo buffalo" Returns: "Good"
This is a good sentence contains two 'buffalo'.
1)
"buffalobuffalo" Returns: "Not good"
There must be exactly one space between two words.
2)
"buffalo buffalo buffalo" Returns: "Good"
3)
"buf falo buffalo" Returns: "Not good"
4)
"cow" Returns: "Not good"
Submissions are judged against all 94 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class BuffaloBuffalo with a public method string check(string s) · 94 test cases · 2 s / 256 MB per case