Have to check whether this is the repeated character that matches the last char of the parent String
while ( remStr . length ( ) > 0 && remStr [ 0 ] != ch && remStr [ 0 ] == s [ s . length ( ) - 1 ] ) { remStr = remStr . substr ( 1 , remStr . length ( ) ) ; } s = s . substr ( 0 , s . length ( ) - 1 ) ; } s = s + remStr ; i = j ; } else { i ++ ; } } return s ; }