Leetcode 1406 Solution
This article provides solution to leetcode question 1406 (subtract-the-product-and-sum-of-digits-of-an-integer)
Access this page by simply typing in "lcs 1406" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer
Solution
class Solution:
def subtractProductAndSum(self, n: int) -> int:
val1 = 1
val2 = 0
for ch in str(n):
val1 *= int(ch)
val2 += int(ch)
return val1 - val2