ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1654. Cipher Message

Test case 6 ? String length =200000 ?
Posted by TruongNT 22 Dec 2015 07:26
My code using 1 while. Time limit at test case 6?


public class CliperMessage_1654 {
    public static void main(String[] arg0) {
        Scanner sc=new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
        sb.append(sc.nextLine());
        if(sb.length()<=200000){
            int i=0;
            while(i<sb.length()-1){
                if((sb.charAt(i)==sb.charAt(i+1))){
                    sb.deleteCharAt(i);
                    sb.deleteCharAt(i);
                }
                else if(((i>=1)&&(sb.charAt(i-1)==sb.charAt(i))))
                {
                    sb.deleteCharAt(i-1);
                    sb.deleteCharAt(i-1);
                    i--;
                }else i++;
            }

        System.out.println(sb);
        }
}
}