Given a number N, we have to find the minimum number of palindromes required to express N as a sum of them.
Input: N = 11
11 is itself a palindrome.
Input: N = 65
65 can be expressed as a sum of three palindromes (55, 9, 1).
We can use Dynamic Programming to solve this problem. The idea is to first generate all the palindromes up to N in a sorted fashion, and then we can treat this problem as a variation of the subset sum problem, where we have to find the size of the smallest subset such that its sum is N.
Below is the implementation of above approach:
- Minimum number of palindromes required to express N as a sum | Set 2
- Minimum number of given powers of 2 required to represent a number
- Minimum number operations required to convert n to m | Set-2
- Minimum number of changes required to make the given array an AP
- Minimum number of operations required to reduce N to 1
- Minimum number of given operation required to convert n to m
- Minimum number of mails required to distribute all the questions
- Minimum number of integers required to fill the NxM grid
- Minimum number of given moves required to make N divisible by 25
- Minimum number of bottles required to fill K glasses
- Minimum number of operations required to sum to binary string S
- Minimum number of given operations required to make two strings equal
- Minimum number of given operations required to reduce the array to 0 element
- Find out the minimum number of coins required to pay total amount
- Minimum number of single digit primes required whose sum is equal to N
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.