python simple 3 lines solution

  • 12
    class Solution(object):
        def complexNumberMultiply(self, a, b):
            :type a: str
            :type b: str
            :rtype: str
            a1, a2 = map(int, a[:-1].split('+'))
            b1, b2 = map(int, b[:-1].split('+'))
            return '%d+%di' % (a1 * b1 - a2 * b2, a1 * b2 + a2 * b1)

Log in to reply

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