If length of string is 1 or 0
if ( s . length ( ) <= 1 ) { return s ; } int i = 0 ; while ( i < s . length ( ) ) { if ( i + 1 < s . length ( ) && s [ i ] == s [ i + 1 ] ) { int j = i ; while ( j + 1 < s . length ( ) && s [ j ] == s [ j + 1 ] ) { j ++ ; } char lastChar = i > 0 ? s [ i - 1 ] : ch ; string remStr = removeDuplicates ( s . substr ( j + 1 , s . length ( ) ) , lastChar ) ; s = s . substr ( 0 , i ) ; int k = s . length ( ) , l = 0 ;