최대 1 분 소요

Python

class Solution:
    def subtractProductAndSum(self, n: int) -> int:
        temp = list(map(int, ' '.join(str(n)).split()))
        product_of_digits = 1
        sum_of_digits = 0
        for i in temp:
            product_of_digits *= i
            sum_of_digits += i
            
        return product_of_digits - sum_of_digits

댓글남기기