Compiler is very slow :(

Compiler is taking too long to run the code.
Has to refresh a lot of times which is furthermore troublesome as the code doesn’t gets saved.

Mistakes:

  1. Make the int x ===> long long int x because the input can greater than 10^9…
  2. if the starting digit of number is 9 then don’t make it 0 (i.e. min(9,9-9) =>0 )
    because if you make it zero ==> then the
    number of digit (in the given number) != number of digit(in the inverted number)

Reference Code:

I hope this helps if you have further doubts feel free to ask