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.
- Sentence Palindrome (Palindrome after removing spaces, dots, .. etc)
- Count all palindrome which is square of a palindrome
- Largest even number possible by using one swap operation in given number
- Check whether the given floating point number is a palindrome
- Check if string remains palindrome after removing given number of characters
- Check whether the string S1 can be made equal to S2 with the given operation
- Check if one string can be converted to other using given operation
- Check if a number with even number of digits is palindrome or not
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Generate a String from given Strings P and Q based on the given conditions
- Transform One String to Another using Minimum Number of Given Operation
- Minimum possible number with the given operation
- Check if a given string is a rotation of a palindrome
- C Program to Check if a Given String is Palindrome
- Check if characters of a given string can be rearranged to form a palindrome
- Given two strings check which string makes a palindrome first
- Check if it is possible to create a palindrome string from given N
- Python program to check if given string is vowel Palindrome
- TCP Client-Server Program to Check if a Given String is Palindrome
- Check whether the given string is Palindrome using Stack
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.