Replace Digit

Asked at Microsoft · Coding & Leetcode-style Questions · Difficulty: Medium

There is a string **S** representing a positive number consisting of N digits. In one move, you can choose some digit of **S** that is not equal to 5 and replace it with the digit 5. What is the maximum number that can be obtained after making exactly **K** moves?

Loading the problem…