Can you please check my code
Hi @aryaman.kumar26,
a lot of changes need to be made in ur code.
first of all, there is no need to sort the string.
eg. input = 123, output should be 876
moreover, in the inputs, first element will never be 0.
and if first element is not zero, ur code is printing only first element.
Follow this approach,
iterate through string.
replace elements of string by 9-(element) if 9-element>element.
if first element = 9, no need to replace else first element will become 0.
For more help, u can refer to the hind video of the same problem. The code is also discussed there.
Hope dis helps.
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.