Python solution


  • 0
    H
    class Solution(object):
        def complexNumberMultiply(self, a, b):
            """
            :type a: str
            :type b: str
            :rtype: str
            """
            idx1=a.find("+")
            r1,c1=int(a[:idx1]),int(a[idx1+1:len(a)-1] )       
            idx1=b.find("+")
            r2,c2=int(b[:idx1]),int(b[idx1+1:len(b)-1])
            r=r1*r2-c1*c2
            c=r1*c2+r2*c1
            res=""+str(r)+"+"+str(c)+"i"
            return res        
            ```

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.