Subtract the Product and Sum of Digits of an Integer
class Solution:
def subtractProductAndSum(self, n: int) -> int:
s, p = 0, 1
for c in str(n):
s = s + int(c)
p = p * int(c)
return p - s
class Solution:
def subtractProductAndSum(self, n: int) -> int:
s, p = 0, 1
for c in str(n):
s = s + int(c)
p = p * int(c)
return p - s