Maximum Product of Two Digits

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.

Example 1
Inputn = 31
Output3
The digits are [3, 1], and the only possible product is 3 * 1 = 3.
Example 2
Inputn = 22
Output4
The digits are [2, 2], so using both occurrences gives the maximum product 2 * 2 = 4.

Constraints

  • 10 <= n <= 10^9

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate