Problems > All Digits Different > Editorial

All Digits Different — Solution & Editorial

Back to the Problem

Digit walk with a used-set: for each prefix position try smaller digits not yet used and multiply falling-factorial choices for the free tail; add 1 if N itself survives. (Beyond 10 digits nothing new qualifies.)

Complexity: O(10 · log N)