X247: gHappy

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.

Examples:

gHappy("xxggxx") -> true
gHappy("xxgxx") -> false
gHappy("xxggyygxx") -> false

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.