Given a number x and two digits d1 and d2, replace d1 with d2 in x.
Input : x = 645, d1 = 6, d2 = 5 Output : 545 We replace digit 6 with 5 in number 645. Input : x = 746, d1 = 7, d2 = 8 Output : 846
We traverse through all digits of x. For every digit, we check if it is d1, we update result accordingly.
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.
- Min steps to convert N-digit prime number into another by replacing a digit in each step
- Count of N-digit numbers having digit XOR as single digit
- Sub-strings that start and end with one character and have at least one other
- Maximum possible GCD after replacing at most one element in the given array
- Check if given number contains a digit which is the average of all other digits
- Divide every element of one array by other array elements
- Given two numbers as strings, find if one is a power of other
- Count pairs in an array such that frequency of one is at least value of other
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Minimum value that divides one number and divisible by other
- Insert N elements in a Linked List one after other at middle position
- Length of array pair formed where one contains all distinct elements and other all same elements
- Check whether one root of the Quadratic Equation is twice of other or not
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Count of integers obtained by replacing ? in the given string that give remainder 5 when divided by 13
- Array value by repeatedly replacing max 2 elements with their absolute difference
- Queries to find the XOR of an Array after replacing all occurrences of X by Y
- Maximum Subarray Sum possible by replacing an Array element by its Square
- Maximize modulus by replacing adjacent pairs with their modulus for any permutation of given Array
- Maximize array sum by replacing equal adjacent pairs by their sum and X respectively
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.