A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.(Wikipedia)
Given a string , print Yes
if it is a palindrome, print No
otherwise.
Constraints
- will consist at most lower case english letters.
Sample Input
madam
Sample Output
Yes
Solution:-
import java.io.*;
import java.util.*;
public class Solution {
public static String palindrome(String n)
{
String s="";
for(int i=n.length()-1;i>=0;i--)
{
s+=n.charAt(i);
}
return (s);
}
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 B=palindrome(A);
if(A.equals(B))
{
System.out.println("Yes");
return;
}
System.out.println("No");
}
}