Python Soultion


  • 0
    I
    class Solution(object):
        def complexNumberMultiply(self, a, b):
            """
            :type a: str
            :type b: str
            :rtype: str
            """
            a1, tmp, a2 = str(a).partition("+")
            b1, tmp, b2 = str(b).partition("+")
            a = int(a1) * int(b1) - int(a2[:-1]) * int(b2[:-1])
            b = int(a1) * int(b2[:-1]) + int(b1) * int(a2[:-1])
            return str(a) + "+" + str(b) + "i"
    

Log in to reply
 

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