2025-08-24 14:41:29 +0000 UTC

Maximum Product of Two Digits

Code

class Solution:
    def maxProduct(self, n: int) -> int:
        dig = []
        while n > 0:
            heapq.heappush(dig, -(n % 10))
            n //= 10
        return abs(heapq.heappop(dig) * heapq.heappop(dig))