Given a integer as a input and replace all the ‘0’ with ‘5’ in the integer.
102 - 152 1020 - 1525
Use of array to store all digits is not allowed.
The idea is simple, we get the last digit using mod operator ‘%’. If the digit is 0, we replace it with 5, otherwise keep it as it is. Then we recur for remaining digits.
Following is the implementation of the above idea.
This article is contributed by Sai Kiran. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Next greater element in same order as input
- Replace every element of the array by sum of all other elements
- Replace every element of the array with BitWise XOR of all other
- Replace every array element by sum of previous and next
- Replace every array element by multiplication of previous and next
- Replace two consecutive equal values with one greater
- Replace every element of the array by product of all other elements
- In-place replace multiple occurrences of a pattern
- Replace duplicates with greater than previous duplicate value
- Replace the maximum element in the array by coefficient of range
- Replace repeating elements with greater that greatest values
- Replace even nodes of a doubly linked list with the elements of array
- Replace each node in binary tree with the sum of its inorder predecessor and successor
- Blum Integer
- Replace each element by the difference of the total size of the array and frequency of that element