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.
I believe inorder to check palindrome we need to check the word is same from backward to forward.
For this i reverse the word by every char and concat to new String and check for Equal value of both String objects.
import java.io.;
import java.util.;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String A=sc.next();
/* Enter your code here. Print output to STDOUT. */
String k ="";
for(int i =A.length()-1;i>=0;i--){
char c = A.charAt(i);
String ch = Character.toString(c);
k = k.concat(ch);
}
if(A.equals(k))
{
System.out.println("Yes");
}
else
System.out.println("No");
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java String Reverse
You are viewing a single comment's thread. Return to all comments →
I believe inorder to check palindrome we need to check the word is same from backward to forward. For this i reverse the word by every char and concat to new String and check for Equal value of both String objects.
import java.io.; import java.util.;
public class Solution {
}