Leetcode 537 Solution
This article provides solution to leetcode question 537 (complex-number-multiplication)
Access this page by simply typing in "lcs 537" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/complex-number-multiplication
Solution
class Solution:
def complexNumberMultiply(self, a: str, b: str) -> str:
ra, va = a.split("+")
ra = int(ra)
va = int(va[:-1])
rb, vb = b.split("+")
rb = int(rb)
vb = int(vb[:-1])
return "{}+{}i".format(ra * rb - va * vb, ra * vb + rb * va)