Failed test cases

I think my code is perfect but it is failing testcases

Hey Rohit,
Sorry to let you know that the implementation you used for this program is not applicable . What you are trying to do is check ,
if (a[i]>(9-a[i]))

    {

        a[i]=9-a[i];

    }

here a[i] is a one digit number, (you can print in case you are not sure) thereby how can one digit number be greater then nine.
I’ll suggest you to read this problem again & understand this thoroughly.Moreover this problem is not what you are understanding.

Uh i am comparing a[i] and 9-a[i] thats why the brackets It is only failing 2 test cases so I guess I am missing some special case

The custom input you are giving is 998999
which brings an output of 1000
whereas the expected output it should give is 901000
Hope you will understand what this problem is :smile:

I see what you mean but when our aim is to calculate the lowest positive number with no leading zeroes right so 987 should invert to 012 and then we omit the 0 no?

You got what i am trying to explain whereas 987 will give an output of 912 not 012.

Yes I got it I just thought our aim was to get lowest number by inverting so I was inverting 987 to 12

Hope you liked my explanation, please rate your experience with me :grinning:

Also, mark your doubt as resolved.