Chewbacca and number

please send me the logic if you are not giving whole code that will be fine too but plz atleast send logic

Logic:
if digit is >5 flip that digit otherwise don’t flip
also check some corner cases
a) first digit should not be zero so if first digit is 9 then it should remain unchanged
b) if number is 0 only then output should be 9, not 0.

Reference 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.