• + 0 comments

    **SUCCESSFULLY COMPLETED THIS PROGRAM ** PLEASE LET ME KNOW, TO OPTIMIZE THIS!!

    // import java.io.; import java.util.;

    public class Solution {

    public static void Testcase(String s)
    {
        char[] ch = s.toCharArray();
        char[] ab = new char[5000];
         char[] bc = new char[5000];
    
        int g=0;
        int h=0;
    
        for(int i=0;i<s.length();i++)
        {
            if(i%2==0)
            {
                ab[g++]=ch[i];
            }
            else
            {
                bc[h++]=ch[i];
            }
        }
        System.out.println(new String(ab,0,g)+" "+new String(bc,0,h));
    
    }
    
    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
    
        int a = sc.nextInt();
        String s;
    
        for(int j=1;j<=a;j++)
        {
            s = sc.next();
            Testcase(s);
        }
    
    }
    

    }