力扣43. 字符串相乘

class Solution:
    def multiply(self, num1: str, num2: str) -> str:
        m ,n = len(num1),len(num2)
        res = [0]*(m+n)
        result = 0
        for i in range(n-1,-1,-1):
            for j in range(m-1,-1,-1):
                res[i+j+1] += (ord(num2[i])-ord('0'))*(ord(num1[j])-ord('0'))%10
                res[i+j]+= (ord(num2[i])-ord('0'))*(ord(num1[j])-ord('0'))//10
        for i in range(len(res)):
            result += res[i]*(10**(len(res)-i-1))
        
        return str(result)

上一篇:java.lang.AbstractMethodError: Method org/apache/commons/dbcp/DelegatingResultSet.getNString(Ljava/l


下一篇:Leetcode - 43. 字符串相乘