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.
- 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 it is possible to create a palindrome string from given N
- Check if any anagram of a string is palindrome or not
- Check if a given string is a rotation of a palindrome
- Check whether the given string is Palindrome using Stack
- C Program to Check if a Given String is Palindrome
- Check if a string is palindrome in C using pointers
- 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
- Python program to check if a string is palindrome or not
- Check if string can be rearranged so that every Odd length Substring is Palindrome
- Python program to check if given string is vowel Palindrome
- TCP Client-Server Program to Check if a Given String is Palindrome
Improved By : nitin mittal