When you want to get all the digits of a integer n, instead of doing n /= 10, n % 10, use to_string(n). It's shorter and less error-prone. For example, you don't need to consider n = 0.
n
n /= 10, n % 10
to_string(n)
n = 0
2191. Sort the Jumbled Numbers (Medium)arrow-up-right
Last updated 2 years ago