Given an integer N the task is to create a string out of it by repeating the number such that the length of the resultant string is equal to the sum of the digits in the original number.
For eg: If the number is 61 and the sum of the digits is 6 + 1 = 7 so the string generated after repeating 61 will be of 7 length i.e. 6161616.
Input: N = 10101
Length of the string is given by sum of the digits i.e. 1 + 0 + 1 + 0 + 1 = 3.
So the resultant string is “101” which is a palindrome.
Input: N = 123
Length of the string will be 1 + 2 3 = 6.
So the resultant string is “123123” which is not a palindrome.
- Find the sum of the digits of N and repeat the number till the length of the string becomes equal to this sum.
- Now check if the resultant string is a palindrome or not.
- If it is a palindrome then 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 number is Palindrome in PL/SQL
- Check if a number is Palindrome
- Program to check the number is Palindrome or not
- Check if number is palindrome or not in Octal
- Recursive program to check if number is palindrome or not
- To check a number is palindrome or not without using any extra space
- Bash program to check if the Number is a Palindrome
- Check whether the given floating point number is a palindrome
- Check if a number with even number of digits is palindrome or not
- Check if actual binary representation of a number is palindrome
- Check if string remains palindrome after removing given number of characters
- Check if one string can be converted to other using given operation
- Check whether the string S1 can be made equal to S2 with the given operation
- Check if a given string is Even-Odd Palindrome or not
- Check if the sum of digits of N is palindrome
- Check if sum of any subarray is Palindrome or not
- Queries to check if substring[L...R] is palindrome or not
- Check if a string is palindrome in C using pointers
- Program to check if an Array is Palindrome or not using STL in C++
- Check if a given string is a rotation of a 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.