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 email@example.com. 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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- 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 any anagram of a string is palindrome or not
- Check if a string is palindrome in C using pointers
- C Program to Check if a Given String is Palindrome
- Check if a given string is a rotation of a palindrome
- Check if both halves of a string are Palindrome or not
- Check given string is oddly palindrome or not | Set 2
- Check given string is oddly palindrome or not
- Check whether the given string is Palindrome using Stack
- Check if it is possible to create a palindrome string from given N
- Python program to check if a string is palindrome or not
- Given two strings check which string makes a palindrome first
- Check if there exists any sub-sequence in a string which is not palindrome
- Java program to check whether a string is a Palindrome
- Python program to check if given string is vowel Palindrome
- Check if a string can be rearranged to form special palindrome
- Check if string can be rearranged so that every Odd length Substring is Palindrome
- Check if characters of a given string can be rearranged to form a palindrome