Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3536 - Maximum Product of Two Digits.

    Easy

    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:

    Input: n = 31

    Output: 3

    Explanation:

    • The digits of n are [3, 1].

    • The possible products of any two digits are: 3 * 1 = 3.

    • The maximum product is 3.

    Example 2:

    Input: n = 22

    Output: 4

    Explanation:

    • The digits of n are [2, 2].

    • The possible products of any two digits are: 2 * 2 = 4.

    • The maximum product is 4.

    Example 3:

    Input: n = 124

    Output: 8

    Explanation:

    • The digits of n are [1, 2, 4].

    • The possible products of any two digits are: 1 * 2 = 2, 1 * 4 = 4, 2 * 4 = 8.

    • The maximum product is 8.

    Constraints:

    • <code>10 <= n <= 10<sup>9</sup></code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer maxProduct(Integer n)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait