Find Whether Given String is palindrome or Not.

Objective : Write an algorithm to find Whether Given String is palindrome or Not.

Input:  A String,

Output: true or false on whether string is palindrome or not


  • Use recursive approach
  • Compare first and last characters if they are not same- return false
  • If they are same make, remove the first and last characters and make a recursive call. 


Jain niaJ => compare ‘J’ with ‘J’ =>returns true

ain nia => compare ‘a’ with ‘a’ =>returns true

in ni => compare ‘i’ with ‘i’ =>returns true

n n => compare ‘n’ with ‘n’ =>returns true

string length <2 => returns true

Complete Code:


Is Sumit Palindrome ??? :false
Is SumuS Palindrome ??? :true
Is ABCDEFGHGFEDCBA Palindrome ??? :true
Is Jain niaJ Palindrome ??? :true
Is SumuaS Palindrome ??? :false

Top Companies Interview Questions..-

Google Microsoft Amazon Facebook more..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.

You may also like...

  • Anonymous

    This program is wrong. Try modifying the second string to SumuaS and check. You will get the wrong result.

    • Sumit Jain

      Thanks for pointing it out…I have corrected it.

  • kaos

    What if the String contains capital letters and small letters in between? Example Nitin . It should return true right?

%d bloggers like this: