We’re preparing your current view and syncing the latest data.
Given a number represented as a string, determine if it is a permutation of the digitorial of some integer n, where digitorial of n is defined as the concatenation of factorials of each digit of n. For example, for n = 12, the digitorial is factorial(1) concatenated with factorial(2) = "1" + "2" = "12".
A single string representing the number to check.
Return 'YES' if the input string is a permutation of the digitorial of some integer; otherwise return 'NO'.
Input string length is between 1 and 20.
Example 1
Input
12
Output
YES
Explanation
Digitorial of 12 is '1' + '2' = '12', which matches the input.
Example 2
Input
121
Output
NO
Explanation
No integer n's digitorial can be permuted to '121'.