You are viewing a single comment's thread. Return to all comments →
for(int i=0;i<(s.length()-1);i++) {
if(s.charAt(i)==s.charAt(i+1)) { s=s.substring(0,i)+ s.substring(i+2); i=0; } } if(s.length()==0) { return "Empty String"; } else { return s; } }
I did something similar but this doesn't work for the testcase "baab" - It prints bb instead of printing Empty String. Could you help me please?
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
for(int i=0;i<(s.length()-1);i++) {
I did something similar but this doesn't work for the testcase "baab" - It prints bb instead of printing Empty String. Could you help me please?