multiply strings

🏠

https://leetcode.com/problems/multiply-strings/

1from functools import reduce
2from string import digits
3
4
5class Solution:
6    def multiply(self, num1: str, num2: str) -> str:
7        a = reduce(lambda acc, n: acc * 10 + digits.index(n), num1, 0)
8        b = reduce(lambda acc, n: acc * 10 + digits.index(n), num2, 0)
9        return str(a * b)