Simple Python

  • 0

    Just convert str into int and do the calculation. No idea why it is a medium level question.

    class Solution(object):
        def complexNumberMultiply(self, a, b):
            :type a: str
            :type b: str
            :rtype: str
            i1, j1 = map(int, a[:-1].split("+"))
            i2, j2 = map(int, b[:-1].split("+"))
            return str(i1*i2 - j1*j2) + "+" + str(i1*j2 + i2*j1) + "i"

Log in to reply

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