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.
- Replace every element of the array with BitWise XOR of all other
- Replace every element of the array by sum of all other elements
- URLify a given string (Replace spaces is %20)
- Replace every array element by sum of previous and next
- Replace duplicates with greater than previous duplicate value
- Replace two consecutive equal values with one greater
- Replace every element of the array by product of all other elements
- Replace every array element by multiplication of previous and next
- In-place replace multiple occurrences of a pattern
- 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
- Replace all elements by difference of sums of positive and negative numbers after that element
- Blum Integer