i got correct answer but unable to pass test case please guide me…
above is my code please consider it
thank you
Chewbacca and Number
Hi @Diwyanshu,
I saw your code, there are some mistakes you have done in your code.
- Since inputs are large and it won’t fit in ‘int’, so rather than integer, take the input as string.
- For every digit you are printing the minimum of (x%10,9-x%10) , but does that work for all cases ?
What if x=90 only? in this case your algo will convert most significant digit into 0 which is clearly mentioned in the question that number should not have zero in the starting. Everything else is fine in your code just handle these two and you will get AC
Refer the code for reference: https://ide.codingblocks.com/s/169901
Thanks,
1 Like