1281. Subtract the Product and Sum of Digits of an Integer

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1281

class Solution:
    def subtractProductAndSum(self, n: int) -> int:
        nums = list(map(int, str(n)))
        return prod(nums) - sum(nums)