fork download
  1. public class OneDigitDifference {
  2.  
  3. public int getSmallest(int N) {
  4. if(N == 0)
  5. return 1;
  6. int[] is = new int[10];
  7. for(int i = 0; i < 10; i++, N /= 10)
  8. is[i] = N % 10;
  9. for(int i = 9; i >= 0; i--)
  10. if(is[i] > 0) {
  11. is[i] = 0;
  12. break;
  13. }
  14. int ret = 0;
  15. for(int i = 9; i >= 0; i--)
  16. ret = ret * 10 + is[i];
  17. return ret;
  18. }
  19. }
Not running #stdin #stdout 0s 0KB
stdin
stdout
Standard output is empty