I'm getting the following error while trying to run my program. This is actually a submission for Hackerrank's "Day 6 Let's review" challenge.
Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:862) at java.util.Scanner.next(Scanner.java:1371) at Solution.main(Solution.java:10)
Here is my code:
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int i=0; i<=T; i++){
String S = sc.next();
for(int j=0; j<S.length(); j++){
if(j%2==0){
System.out.print(S.charAt(j));
}
}
System.out.print(" ");
for(int r=0; r<S.length(); r++){
if(r%2!=0){
System.out.print(S.charAt(r));
}
}
System.out.println("");
}
}