Find the largest product obtainable by choosing any two digits from a number.
Given a non-negative integer, consider the decimal digits that appear in it. Your task is to choose two different digits from the number and return the maximum possible product of those two digits.
If the number has fewer than two digits, the problem is not well-defined for forming a pair. In practice, such cases should be handled safely by returning 0.
Because only the digits matter, the order in which they appear does not affect the product.
Compute the largest product of any two digits in the input number.
n.n.0 <= n0 to 9.0.Example 1
Input
n = 2736
Output
18
Explanation
The digits are 2, 7, 3, and 6. The largest product comes from 6 × 3 = 18.
Example 2
Input
n = 909
Output
81
Explanation
The digits are 9, 0, and 9. The best pair is 9 × 9 = 81.
Example 3
Input
n = 7
Output
0
Explanation
There is only one digit, so no pair can be formed. Returning 0 is the safest convention.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.