class Solution:
def subtractProductAndSum(self, n: int) -> int:
def get_product_of_an_integer(n):
mul = 1
while n:
mul *= n%10
n //= 10
return mul
def get_sum_of_an_integer(n):
sum = 0
while n:
sum += n % 10
n //= 10
return sum
return get_product_of_an_integer(n)-get_sum_of_an_integer(n)
1281.Subtract the Product and Sum of Digits of an Integer
最新推荐文章于 2024-08-18 18:02:49 发布