Closed Karthiks08 closed 3 years ago
class Solution {
public String makeGood(String s) { if(s.length()<=1) return s; int i=0, j=1; StringBuilder sb = new StringBuilder(s); while(j < sb.length() && sb.length() > 1) { if(Math.abs(sb.charAt(i) - sb.charAt(j)) == 32) { sb.deleteCharAt(i); sb.deleteCharAt(i); if(i>0) i = i-1; j = i+1; continue; } i++;j++; } return sb.toString(); }
}
class Solution {
}