Java Sample Programs Hackerrank
Java Sample Programs Hackerrank
The code stubs in your editor declare a Solution class and a main method. Complete
the main method by copying the two lines of code below and pasting them inside the
body of your main method.
System.out.println("Hello, World.");
System.out.println("Hello, Java.");
Input Format
Output Format
Sample Output
Hello, World.
Hello, Java.
Solution:
System.out.println("Hello, World.");
System.out.println("Hello, Java.");
Constraints
Sample Input
madam
Sample Output
Yes
Soution’
import java.io.*;
import java.util.*;
String A=sc.next();
int i = 0;
int j = A.length()-1;
while (i<j)
if(A.charAt(i) != A.charAt(j))
isTrue = false;
i++;
j--;
if(isTrue)
System.out.println("Yes");
else
System.out.println("No");