Given a number N. The task is to create an alphabetical string in lower case from that number and tell whether the string is palindrome or not. a = 0, b = 1….. and so on.
For eg: If the number is 61 the substring “gb” will be printed till 7 (6+1) characters i.e. “gbgbgbg” and check if palindrome or not.
Note: No number will start with zero. Consider alphabets ‘ a to j ‘ only i.e. single digit numbers from 0 to 9.
Input: N = 61
Numbers 6, 1 represent letters ‘g’, ‘b’ respectively. So the substring is ‘gb’ and the sum is 7(6+1). Thus the alphabetical string formed is ‘gbgbgbg’, and is a palindrome.
Input: N = 1998
Numbers 1, 9, 8 represent letters ‘b’, ‘j’ and ‘i’ respectively. So the substring is ‘bjji’ and sum is 27(1+9+9+8). Thus the alphabetical string formed is bjjibjjibjjibjjibjjibjjibjj’, and is not a palindrome.
- Obtain the substring corresponding to given number N and maintain its digit’s sum.
- Append the substring till its length becomes equal to the sum of digits of N.
- Check if the string obtained is Palindrome or not.
- If it is a Palindrome, print YES.
- Else, print NO.
Below is the implementation of the above approach:
- Check if a string is palindrome in C using pointers
- Check if any anagram of a string is palindrome or not
- Check if a given string is a rotation of a palindrome
- C Program to Check if a Given String is Palindrome
- Recursive function to check if a string is palindrome
- Given two strings check which string makes a palindrome first
- 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
- Check if a string can be rearranged to form special palindrome
- Check if characters of a given string can be rearranged to form a palindrome
- Python program to check if given string is vowel Palindrome
- TCP Client-Server Program to Check if a Given String is Palindrome
- Check if the characters in a string form a Palindrome in O(1) extra space
- Create a new string by alternately combining the characters of two halves of the string in reverse
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ihritik