You are viewing a single comment's thread. Return to all comments →
public static void main(String... args) { Scanner stdin = new Scanner(System.in); StringBuffer s = new StringBuffer(stdin.nextLine()); for(int i = 1; i < s.length(); i++) { if(s.charAt(i) == s.charAt(i-1)) { s.delete(i-1, i+1); if( i-1 > 0) i = i-2; else i = 0; } } if(s.length() == 0) System.out.println("Empty String"); else System.out.println(s); }
We can also do this?
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
We can also do this?