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:
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.
- Check if a given string is Even-Odd Palindrome or not
- Check if a string is palindrome in C using pointers
- Check if both halves of a string are Palindrome or not
- Check whether the given string is Palindrome using Stack
- C Program to Check if a Given String is Palindrome
- Check given string is oddly palindrome or not
- Check if a given string is a rotation of a palindrome
- Check if any anagram of a string is palindrome or not
- Check given string is oddly palindrome or not | Set 2
- Recursive function to check if a string is palindrome
- Python program to check if a string is palindrome or not
- Given two strings check which string makes a palindrome first
- Java program to check whether a string is a Palindrome
- Check if there exists any sub-sequence in a string which is not palindrome
- TCP Client-Server Program to Check if a Given String is 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
- Check if string is palindrome after removing all consecutive duplicates
- Python program to check if given string is vowel Palindrome
- Check if a string can be rearranged to form special palindrome
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