Given two numbers N and K, the task is to check whether the given number N can be made a palindromic after adding K to it.
Input: N = 19, K = 3
19 + 3 = 22 and 22 is a palindrome.
Input: N = 15, K = 3
15 + 3 = 18 and 18 is not a palindrome.
Approach: The idea is to first add K to the given number and then check if the obtained number is a palindrome or not.
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 whether the number can be made perfect square after adding 1
- Check whether the number can be made perfect square after adding K
- Check whether N can be a Perfect Cube after adding or subtracting K
- Check if given intervals can be made non-overlapping by adding/subtracting some X
- Queries to check whether all the elements can be made positive by flipping signs exactly K times
- Check whether an Array can be made 0 by splitting and merging repeatedly
- Check if X and Y can be made zero by using given operation any number of times
- Check if given array can be made 0 with given operations performed any number of times
- Check if number can be made prime by deleting a single digit
- Check if elements of array can be made equal by multiplying given prime numbers
- Check if all elements of the given array can be made 0 by decrementing value in pairs
- Check if N and M can be made equal by increasing N by A and decreasing M by B
- Check if all elements of a Circular Array can be made equal by increments of adjacent pairs
- Longest Palindromic Substring using Palindromic Tree | Set 3
- Make palindromic string non-palindromic by rearranging its letters
- Minimum cuts required to convert a palindromic string to a different palindromic string
- Total number of different staircase that can made from N boxes
- Largest number divisible by 90 that can be made using 0 and 5
- Number of words that can be made using exactly P consonants and Q vowels from the given string
- Check if K palindromic strings can be formed from a given string
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.