Simple Python solution


  • 0
    class Solution(object):
        def complexNumberMultiply(self, a, b):
            """
            :type a: str
            :type b: str
            :rtype: str
            """
            A = int(a.split('+')[0])
            B = int(a.split('+')[1][:-1])
            C = int(b.split('+')[0])
            D = int(b.split('+')[1][:-1])
            return str((A*C-B*D)) + '+' +str(B*C+A*D)+'i'
    

Log in to reply
 

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