LeetCode知识点总结 - 537
LeetCode 537. Complex Number Multiplication考点难度MathMedium题目A complex number can be represented as a string on the form “realimaginaryi” where:real is the real part and is an integer in the range [-100, 100].imaginary is the imaginary part and is an integer in the range [-100, 100].i2 -1.Given two complex numbers num1 and num2 as strings, return a string of the complex number that represents their multiplications.思路(a bi) * (c di) (ac - bd) (ad bc)i答案classSolution{publicStringcomplexNumberMultiply(Stringa,Stringb){int[]coefs1Stream.of(a.split(\\|i)).mapToInt(Integer::parseInt).toArray(),coefs2Stream.of(b.split(\\|i)).mapToInt(Integer::parseInt).toArray();return(coefs1[0]*coefs2[0]-coefs1[1]*coefs2[1])(coefs1[0]*coefs2[1]coefs1[1]*coefs2[0])i;}}