3848. Check Digitorial Permutation Medium

@problem@discussion
#Math#Counting



1/**
2 * [3848] Check Digitorial Permutation
3 *
4 * You are given an integer n.
5 * A number is called digitorial if the sum of the factorials of its digits is equal to the number itself.
6 * Determine whether any permutation of n (including the original order) forms a digitorial number.
7 * Return true if such a permutation exists, otherwise return false.
8 * Note:
9 * 
10 * 	The factorial of a non-negative integer x, denoted as x!, is the product of all positive integers less than or equal to x, and 0! = 1.
11 * 	A permutation is a rearrangement of all the digits of a number that does not start with zero. Any arrangement starting with zero is invalid.
12 * 
13 *  
14 * <strong class="example">Example 1:
15 * <div class="example-block">
16 * Input: <span class="example-io">n = 145</span>
17 * Output: <span class="example-io">true</span>
18 * Explanation:
19 * The number 145 itself is digitorial since 1! + 4! + 5! = 1 + 24 + 120 = 145. Thus, the answer is true.
20 * </div>
21 * <strong class="example">Example 2:
22 * <div class="example-block">
23 * Input: <span class="example-io">n = 10</span>
24 * Output: <span class="example-io">false</span>
25 * Explanation:​​​​​​​
26 * 10 is not digitorial since 1! + 0! = 2 is not equal to 10, and the permutation "01" is invalid because it starts with zero.
27 * </div>
28 *  
29 * Constraints:
30 * 
31 * 	1 <= n <= 10^9
32 * 
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/check-digitorial-permutation/
37// discuss: https://leetcode.com/problems/check-digitorial-permutation/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42    pub fn is_digitorial_permutation(n: i32) -> bool {
43        false
44    }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_3848() {
55    }
56}
57

Back
© 2026 bowen.ge All Rights Reserved.