The string you'll received as a parameter has too many characters. Your job is to
Remove characters from the string in the following order:
1. Find the smallest i such that the i-th character and the (i+1)-th character of the string is same.
2. If There is no such I, end the process.
3. Remove the i-th and the (i+1)-th character of the string, and repeat from 1.
For example, if the parameter is "AYQQYJJJ", she'll change the string as follows: "AYQQYJJJ", "AYYJJJ", AJ JJ "," AJ ".
Return the resulting string
1 Public classdigui{2 Static Private intT=0;3 Static Private intLen;4 Static PrivateString S;5 Public Static voidFintN) {6t++;7 while(T<len&&s.charat (n)!=s.charat (n+1))8F (n+1);9 if(T==len)return;Ten Else{ OneS=s.substring (0,n) +s.substring (n+2, S.length ()); At++; - } - } the Private StaticString Eraser () { -len=s.length (); - if(len!=0) F (0); - returns; + } - Public Static voidMain (string[] args) { +S= "ADDAEFG"; A System.out.println (Eraser ()); at } -}
Recursive implementation of a "recurring character" in the removal string