Help! LONGSEQ

maybe there is some issue with the size of character array

/* package codechef; // don’t place package name! */

import java.util.Arrays;
import java.util.Scanner;

/* Name of the class has to be “Main” only if the class is public. */
class CodechefLONGSEQ {

public static void main(String[] args) throws java.lang.Exception {
    try{
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            String str = sc.next();
            char[] array = str.toCharArray();
            Arrays.sort(array);
            System.out.println(((array[0] == '0' & array[1] == '1') || (array[str.length() - 2] == '0' & array[str.length() - 1] == '1') ? "Yes" : "No"));
        }

    }catch(Exception e){}
}

}

Please format your code, or link to a solution - the forum software mangles it otherwise! :slight_smile:

/* package codechef; // don't place package name! */


import java.util.Arrays;
import java.util.Scanner;

/* Name of the class has to be "Main" only if the class is public. */
class CodechefLONGSEQ {

    public static void main(String[] args) throws java.lang.Exception {
        try{
            Scanner sc = new Scanner(System.in);
            int t = sc.nextInt();
            while (t-- > 0) {
                String str = sc.next();
                char[] array = str.toCharArray();
                Arrays.sort(array);
                System.out.println(((array[0] == '0' & array[1] == '1') || (array[str.length() - 2] == '0' & array[str.length() - 1] == '1') ? "Yes" : "No"));
            }

        }catch(Exception e){}
    }
}
1 Like

Thanks - consider the testcase:

1                       
1
1 Like

here is the link of my code
https://www.codechef.com/viewsolution/26207714

thank you so much :slight_smile:

1 Like