You are viewing a single comment's thread. Return to all comments →
This is also passing all the testcases and also reducing the time complexities as both the loops only have to run for (in.length()/2) times...!!!!
public class Solution {
public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int j=0;j<t;j++) { String in = sc.next(); for( int i=0;i<in.length() ;i=i+2) { System.out.print(in.charAt(i)); } System.out.print(" "); for(int i=1;i<in.length();i=i+2) { System.out.print(in.charAt(i)); } System.out.println(); } }
}
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 →
This is also passing all the testcases and also reducing the time complexities as both the loops only have to run for (in.length()/2) times...!!!!
public class Solution {
}