i dont have any idea how to solve it
I dont have any idea how to solve it
hello @Aditya-Kushwaha-914550392281281
its an easy problem.
read a number as string (say s) .
if left most character is ‘9’
- then leave the leftmost character as it is and for other characters simpl replace s[i] with min(s[i],‘9’-s[i])
else:
- for each i replace s[i] with min(s[i],‘9’-s[i])
print s
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.
https://ide.codingblocks.com/s/270017 its a sample code just to take array input why its taking input so much big just see the output of the code after running
Your code is not giving the correct output.
Refer the approach from above. You can refer this implementation https://ide.codingblocks.com/s/270038
why u have condition in the loop if t==n && i==0 do nothing
why u have condition in the loop if t==n && i==0 do nothing
Because consider a case
9999
This will be converted to 9000
Note that if leading digit is 9, it cannot be converted to a 0.(It is mentioned in the question)
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.