Maximum Product of Two Digits - Problem
You are given a positive integer n. Return the maximum product of any two digits in n.
Note: You may use the same digit twice if it appears more than once in n.
Input & Output
Example 1 — Basic Case
$
Input:
n = 253
›
Output:
25
💡 Note:
The digits are 2, 5, and 3. The maximum product is 5 × 5 = 25 (using digit 5 twice)
Example 2 — Single Digit Repeated
$
Input:
n = 99
›
Output:
81
💡 Note:
The digits are 9 and 9. The maximum product is 9 × 9 = 81
Example 3 — Different Digits
$
Input:
n = 1234
›
Output:
16
💡 Note:
The digits are 1, 2, 3, and 4. The maximum product is 4 × 4 = 16
Constraints
- 10 ≤ n ≤ 109
- n is a positive integer
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code