Ok i see i cant test. Anyways my logic is:

First check out how many positions and which we need to change to make it palindrome. Lets say x positions are needed (consider only one half, we are going to make it equal to the other half.) . Now we have k-x extra changes left. First change those positions where change is needed i.e say at i, s[i]!=s[n-i]. So do s[i]=max(s[i],s[n-i]). Run a greedy algorithm from first position (do everything in first half) . If current position doesnt need a change we see if we can make it larger i.e digit here is not 9. If yes, we will need 2 extra changes if we want to change here. Now suppose pos was a position of change. So we need 1 extra change for this position to make it larger.

answered
**26 Jun '18, 11:53**

6★soham1234

1.8k●6●14

accept rate:
22%