public static boolean process(String str){ int count = 1; for(int index = 0;index < str.length() - 1;++index){ if(str.charAt(index) == str.charAt(index + 1)){ ++count; str = str.substring(0,index) + str.substring(index + 2); index -= 2; } } System.out.println(str); return count % 2 != 0; }