본문 바로가기
python-algorithm

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

by 무적김두칠 2021. 7. 15.

1
2
3
4
5
6
7
8
class Solution:
    def subtractProductAndSum(self, n: int-> int:
        a,b=1,0
        n=str(n)
        for i in n:
            a*=int(i)
            b+=int(i)
        return a-b
cs
반응형

댓글