3536. 两个数字的最大乘积

题目链接:https://leetcode.cn/problems/maximum-product-of-two-digits/description/

Java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Solution {
public int maxProduct(int n) {
int a = 0, b = 0;
while(n > 0) {
if (n % 10 > a) {
b = a;
a = n % 10;
} else if (n % 10 > b){
b = n % 10;
}
n /= 10;
}
return a * b;
}
}

3536. 两个数字的最大乘积
https://pisces34.github.io/2025/05/08/leetcode/3536/
发布于
2025年5月8日
许可协议