Trains the technique from
LeetCode 3848Check Digitorial PermutationThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Take each digit of n, work out its factorial, and add those factorials together. Call the result the factorial total of n, taking 0! to be 1.
Return true when the digits of the factorial total are a rearrangement of the digits of n, that is when the two numbers use exactly the same digits the same number of times.
Example 1
The digit factorials are 1, 120 and 24, which come to 145. Those digits are a rearrangement of 1, 5 and 4.
Example 2
The digit factorials 1, 2 and 6 come to 9, which uses a digit that 123 does not.
Example 3
The digit factorials 24, 1, 120, 40320 and 120 come to 40585, the number itself.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def is_digitorial_permutation(n: int) -> bool:public boolean isDigitorialPermutation(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.