Ad
  • Custom User Avatar

    why was the Ladder class created if it is not used anywhere?

  • Custom User Avatar

    This solution is elegant, but has poor performance due to the fact that the sum of the digits of a single number can be calculated more than once in the sort() function.
    So the complexity is O(m⋅logm⋅k), where
    "m" is the number of numbers,
    "k" is the average length of the number.
    My solution calculates the weights once, so its complexity is O(m⋅k+m⋅logm).
    On the other hand, if we assume that "k" is 2, that is, a constant (hardly anyone weighs more than 999), then the complexity in this and in my case becomes equal to O(m⋅logm). In addition, my solution consumes more memory. So decide for yourself what you like best.