537-Complex-Number-Multiplication
Sat 17 May 2025
https://leetcode.com/problems/complex-number-multiplication
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def complexNumberMultiply(self, a: str, b: str) -> str:
def getRealAndImag(s: str) -> tuple:
return int(s[:s.index('+')]), int(s[s.index('+') + 1:-1])
A, B = getRealAndImag(a)
C, D = getRealAndImag(b)
return str(A * C - B * D) + '+' + str(A * D + B * C) + 'i'
new Solution().complexNumberMultiply()
Score: 5
Category: leetcode