#59. 判断字符串中所有'g'是否快乐

    ID: 59 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-3gesp3字符串

判断字符串中所有'g'是否快乐

Happy 'g'

Background

Congcong is currently learning string processing and has encountered an interesting problem.

Problem Description

We'll say that a lowercase 'g' in a string is "happy" if there is another 'g' immediately to its left or right. Return true if all the 'g's in the given string are happy.

Input Format

Input is given from standard input in the following format.

A string ss.

Output Format

Output is printed to standard output in the following format.

Output true if all 'g's are happy, otherwise output false.

Sample

xxggxx
true
xxgxx
false
xxggyygxx
false

Sample Explanation

Sample 1: The string is "xxggxx". The first 'g' has a 'g' to its right, and the second 'g' has a 'g' to its left. All 'g's are happy, so output true. Sample 2: The string is "xxgxx". The only 'g' has no 'g' to its left or right. It is not happy, so output false. Sample 3: The string is "xxggyygxx". The first two 'g's are happy. However, the last 'g' has no 'g' to its left or right. It is not happy, so output false.

Constraints

The length of string ss is between 00 and 100100. The string ss contains only lowercase English letters.