1281. Subtract the Product and Sum of Digits of an Integer Easy

@problem@discussion
#Math



1/**
2 * [1281] Subtract the Product and Sum of Digits of an Integer
3 *
4 * Given an integer number n, return the difference between the product of its digits and the sum of its digits.
5 *  
6 * Example 1:
7 * 
8 * Input: n = 234
9 * Output: 15 
10 * Explanation: 
11 * Product of digits = 2 * 3 * 4 = 24 
12 * Sum of digits = 2 + 3 + 4 = 9 
13 * Result = 24 - 9 = 15
14 * 
15 * Example 2:
16 * 
17 * Input: n = 4421
18 * Output: 21
19 * Explanation: 
20 * Product of digits = 4 * 4 * 2 * 1 = 32 
21 * Sum of digits = 4 + 4 + 2 + 1 = 11 
22 * Result = 32 - 11 = 21
23 * 
24 *  
25 * Constraints:
26 * 
27 * 	1 <= n <= 10^5
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/
33// discuss: https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn subtract_product_and_sum(n: i32) -> i32 {
39        0
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_1281() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.