Hey @deepak147852
So basically in this question, you’ll be given a number, and you can edit the number to make it the smallest possible number.
The editing can be done in the following way:
pick up any digit t, you can make it 9-t,
so basically we know that, if a digit t is <5, 9- t will be greater than t, so in that case we should not edit digits < 5
for digits >=5 , 9-digit will be less than the digit, so we should edit them to make 9-digit.
for example in the giveb string 4545,
for the first digit 4, if we make 9-4, it will become a greater number, coz 4 is less than 5, we don’t edit it,
we edit 5, and make it 4 which results in a smaller number, and so on. so resulant smallest number possible will be 4444.
Now in all this procedure keep in mind that, if 9 is at the first digit editing it and converting it into 0 will make the number start with 0, you don’t have to do that.