Given a string, write a recursive function that check if the given string is palindrome, else not palindrome.
Input : malayalam Output : Yes Reverse of malayalam is also malayalam. Input : max Output : No Reverse of max is not max.
We have discussed an iterative function here.
The idea of recursive function is simple :
1) If there is only one character in string return true. 2) Else compare first and last characters and recur for remaining substring.
Below is the implementation of above idea :
This article is contributed by Sahil Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Recursive program to check if number is palindrome or not
- String slicing in Python to check if a string can become empty by recursive deletion
- Check if a given string is Even-Odd Palindrome or not
- Check if it is possible to create a palindrome string from given N
- Check given string is oddly palindrome or not | Set 2
- Check if a string is palindrome in C using pointers
- Check if a given string is a rotation of a palindrome
- Check whether the given string is Palindrome using Stack
- Check given string is oddly palindrome or not
- Check if any anagram of a string is palindrome or not
- C Program to Check if a Given String is Palindrome
- Python program to check if a string is palindrome or not
- Java program to check whether a string is a Palindrome
- Check if there exists any sub-sequence in a string which is not palindrome
- Given two strings check which string makes a palindrome first
- Check if characters of a given string can be rearranged to form a palindrome
- Check if string can be rearranged so that every Odd length Substring is Palindrome
- Check if string is palindrome after removing all consecutive duplicates
- Check if a string can be rearranged to form special palindrome
- TCP Client-Server Program to Check if a Given String is Palindrome
Improved By : nitin mittal