Java Program to find a String is Pallindrome or not


You have been given a String “S” and you have 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.


class TestClass {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(;
        String S = br.readLine();
        char[] ch = new char[S.length()];

        for(int i=0;i<S.length();i++) {
            ch[i] = S.charAt(i);
        String T = "";
        for(int i=S.length()-1;i>=0;i--) {
        if(S.equals(T)) {
        } else {

To solve this program on HackerEarth click here.

To check more programs click here.

One Response

  1. turkce says:

    Everything is very open with a clear description of the challenges. It was truly informative. Your website is useful. Many thanks for sharing! Walliw Derward Sephira

Leave a Reply

Your email address will not be published. Required fields are marked *