not getting proper output
Chewbacca and number question
hello @guptashubham210a

correct output is 9000 .
approach is simple
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 have done using array my code is working for all testcases but for number having 9 at starting giving weiird output.
I am not getting througg string array
getting error by this approach
i have already shared the correct snippet.
pls check
I am asking about your approach that you have told by using string
ok,
pls check ur updated code here.
the issue was related to typecasting.
so store ‘9’-n[i]+‘0’ in some character and then use it for comparasion
pls check ->
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.

