Date and Time: May 3, 2025
Link: https://leetcode.com/problems/maximum-product-of-two-digits
class Solution:
def maxProduct(self, n: int) -> int:
# Q: Return the max product of any two digits
# S: Find the biggest and the second biggest digit
# TC: O(n), n=len(n), SC: O(1)
first, second = 0, 0
while n:
if n % 10 > first:
first, second = n % 10 , first
elif n % 10 > second:
second = n % 10
n //= 10
return first * secondTime Complexity:
Space Complexity: