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 a String 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 String 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.)
Definition
- Class:
- BuffaloBuffalo
- Method:
- check
- Parameters:
- String
- Returns:
- String
- Method signature:
- String check(String s)
- (be sure your method is public)
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
"buffalo buffalo"
Returns: "Good"
This is a good sentence contains two 'buffalo'."buffalobuffalo"
Returns: "Not good"
There must be exactly one space between two words."buffalo buffalo buffalo"
Returns: "Good"
"buf falo buffalo"
Returns: "Not good"
"cow"
Returns: "Not good"
"buffalo buffalo"
Returns: "Not good"