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.

AnswerBot
4mo

Calculate the product of two complex numbers represented as strings in the form 'A+Bi'.

  • Parse the input strings to extract real and imaginary parts of both complex numbers

  • Perform multiplication of the ...read more

Help your peers!
Select
Add answer anonymously...

Jaguar Land Rover Software Developer interview questions & answers

A Software Developer was asked Q. SELL ABD BUY 1 array question(easy level)
A Software Developer was asked Q. Beautiful String Verification Given a non-empty string inputString, determine if...read more
A Software Developer was asked Q. K Centers Selection Problem In Ninja Land, there are cities numbered from 0 to N...read more

Popular interview questions of Software Developer

A Software Developer was asked Q1. SELL ABD BUY 1 array question(easy level)
A Software Developer was asked Q2. Beautiful String Verification Given a non-empty string inputString, determine if...read more
A Software Developer was asked Q3. K Centers Selection Problem In Ninja Land, there are cities numbered from 0 to N...read more
Jaguar Land Rover Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits