Ad
  • Custom User Avatar

    Did you evaluate the asymptotic complexity of the algorithm? It is probably O(n log(n)), where n is the number of digits of the number (you need n steps to find the first digit to swap, and then you want to sort the digits on the right). I guess hard numbers are hard only if the algorithm is wrong, but I see a lot of people whose program times out so I guess they already trip in bad cases...