537. Complex Number Multiplication Medium

@problem@discussion
#Math#String#Simulation



1/**
2 * [537] Complex Number Multiplication
3 *
4 * A <a href="https://en.wikipedia.org/wiki/Complex_number" target="_blank">complex number</a> can be represented as a string on the form "real+imaginaryi" where:
5 * 
6 * 	real is the real part and is an integer in the range [-100, 100].
7 * 	imaginary is the imaginary part and is an integer in the range [-100, 100].
8 * 	i^2 == -1.
9 * 
10 * Given two complex numbers num1 and num2 as strings, return a string of the complex number that represents their multiplications.
11 *  
12 * Example 1:
13 * 
14 * Input: num1 = "1+1i", num2 = "1+1i"
15 * Output: "0+2i"
16 * Explanation: (1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i, and you need convert it to the form of 0+2i.
17 * 
18 * Example 2:
19 * 
20 * Input: num1 = "1+-1i", num2 = "1+-1i"
21 * Output: "0+-2i"
22 * Explanation: (1 - i) * (1 - i) = 1 + i2 - 2 * i = -2i, and you need convert it to the form of 0+-2i.
23 * 
24 *  
25 * Constraints:
26 * 
27 * 	num1 and num2 are valid complex numbers.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/complex-number-multiplication/
33// discuss: https://leetcode.com/problems/complex-number-multiplication/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn complex_number_multiply(num1: String, num2: String) -> String {
39        String::new()
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_537() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.