Complex Number Multiplication
Calculate the product of two complex numbers represented as strings in the form “A+Bi”. Here, ‘A’ represents the real part, and ‘B’ represents the imaginary part.
Explanation
You will be given two complex numbers as strings, 'NUM1' and 'NUM2'. Your task is to find their product and return it in the same string format "A+Bi", where ‘A’ is the real part and ‘B’ is the imaginary part of the result.
Input:
The first line contains an integer ‘T’ representing the number of test cases. Each test case consists of two lines:
- The first line contains the string representing the first complex number 'NUM1'.
- The second line contains the string representing the second complex number 'NUM2'.
Output:
For each test case, return the result of the complex multiplication as a string in the form "A+Bi".
Example:
Input:
T = 1
NUM1 = "1+1i"
NUM2 = "1+1i"
Output:
-0+2i
Constraints:
1 ≤ T ≤ 105
-107 ≤ A, B ≤ 107
- Time Limit: 1 sec
Note:
Printing is not required; focus on implementing the function that processes the logic and returns the result.
Be the first one to answer
Add answer anonymously...
Top Jaguar Land Rover Software Developer interview questions & answers
Popular interview questions of Software Developer
>
Jaguar Land Rover Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app