We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
**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);
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 6: Let's Review
You are viewing a single comment's thread. Return to all comments →
**SUCCESSFULLY COMPLETED THIS PROGRAM ** PLEASE LET ME KNOW, TO OPTIMIZE THIS!!
// import java.io.; import java.util.;
public class Solution {
}