Nobita and String - Hackerearth


JAVA Solution



import java.util.Scanner;
class Test {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while(t-- > 0) {
String s = sc.nextLine();
String str[] = s.split(" ");
for(int i = str.length - 1; i >= 0; i--)
System.out.print(str[i] + " ");
System.out.println();
}
}
}



To try this on Hackerearth

Comments

Popular posts from this blog

Balanced Binary Tree

First Unique Character in a String

Majority Element

Smallest Range II