Please give some hint on how to solve this problem

Please give some hint on how to solve this problem

@KetanPandey,
Try to think greedily, e.g decreasing more significant digits will decrease the number greatly.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Please tell me test case 2 and 4

The code is not passing these test cases

if digits are greater than 5 then replace it with 9 - digit except when the first digit is 9 then dont replace it.
Code:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.