You have been given a String S. You need to find and print whether this string is a palindrome or not. If yes, print "YES" (without quotes), else print "NO" (without quotes).
Input Format
The first and only line of input contains the String S. The String shall consist of lowercase English alphabets only.
Output Format
Print the required answer on a single line.
Constraints 1|S|100
Note
String S consists of lowercase English Alphabets only.
SAMPLE INPUT
aba
SAMPLE OUTPUT
YES




  Solution-




import java.util.*;
class Stringpal{
    public static void main(String[] args) {
        String S;
        Scanner sc =new Scanner(System.in);
        S=sc.nextLine();
        S=S.toLowerCase();
        int len=S.length();
        String rev="";
        for(int i=len-1;i>=0;i--)//aba
        {
            rev+=S.charAt(i);
        }
        if(S.equals(rev))
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
    }
}

Post a Comment

Previous Post Next Post