3 out of 5 test cases are getting passed if i am using this code https://ide.codingblocks.com/s/325165
Please tell what is wrong in this?
What i did it in the number is that if digit is greater than or equal to 5 then subtract it from 9.
Test cases not getting passed completely
It is mentioned in the question that the first digit cannot be zero but if the first digit is 9, it will be set to zero according to your code. Please correct that.
If my answer was able to answer your query, please mark the doubt as resolved.
No it wont …I tested it on various test cases in which first digit is 9.
For eg 9250
You can’t create and erase zeros, you can simple put a if check that if MSB is 9, then don’t change it to 0.
if x=9888
then answer should be 9111
not 111