3536. Maximum Product of Two Digits Easy

@problem@discussion
#Math#Sorting



1/**
2 * [3536] Maximum Product of Two Digits
3 *
4 * You are given a positive integer n.
5 * Return the maximum product of any two digits in n.
6 * Note: You may use the same digit twice if it appears more than once in n.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">n = 31</span>
11 * Output: <span class="example-io">3</span>
12 * Explanation:
13 * 
14 * 	The digits of n are [3, 1].
15 * 	The possible products of any two digits are: 3 * 1 = 3.
16 * 	The maximum product is 3.
17 * </div>
18 * <strong class="example">Example 2:
19 * <div class="example-block">
20 * Input: <span class="example-io">n = 22</span>
21 * Output: <span class="example-io">4</span>
22 * Explanation:
23 * 
24 * 	The digits of n are [2, 2].
25 * 	The possible products of any two digits are: 2 * 2 = 4.
26 * 	The maximum product is 4.
27 * </div>
28 * <strong class="example">Example 3:
29 * <div class="example-block">
30 * Input: <span class="example-io">n = 124</span>
31 * Output: <span class="example-io">8</span>
32 * Explanation:
33 * 
34 * 	The digits of n are [1, 2, 4].
35 * 	The possible products of any two digits are: 1 * 2 = 2, 1 * 4 = 4, 2 * 4 = 8.
36 * 	The maximum product is 8.
37 * </div>
38 *  
39 * Constraints:
40 * 
41 * 	10 <= n <= 10^9
42 * 
43 */
44pub struct Solution {}
45
46// problem: https://leetcode.com/problems/maximum-product-of-two-digits/
47// discuss: https://leetcode.com/problems/maximum-product-of-two-digits/discuss/?currentPage=1&orderBy=most_votes&query=
48
49// submission codes start here
50
51impl Solution {
52    pub fn max_product(n: i32) -> i32 {
53        0
54    }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61    use super::*;
62
63    #[test]
64    fn test_3536() {
65    }
66}
67

Back
© 2026 bowen.ge All Rights Reserved.