http://www.javabat.com/prob?id=String3.gHappy We'll say that a lowercase 'g' in a string is "happy" if there isanother 'g' immediately to its left or right. Return true if allthe g's in the given...

http://www.javabat.com/prob?id=String3.gHappy We'll say that a lowercase 'g' in a string is "happy" if there isanother 'g' immediately to its left or right. Return true if allthe g's in the given string are happy. gHappy("xxggxx") ? true gHappy("xxgxx") ? false gHappy("xxggyygxx") ? false //What I have the didn't work. For 1, it has issues with 3 g's in arow is a problem.z public boolean gHappy(String str) { for (int i=0; i if('g' ==str.charAt(i)){ if(!str.substring(i, i+2).equals("gg")) return false; } } return true;

May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here