FastPrepComplex Number Class

Complex Number Class

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREEN

Updated

Problem statement

Construct two integer complex numbers, add them, compare them for equality, and format them. Return [formattedSum, equality, formattedFirst, formattedSecond].

Formatting omits zero terms, writes coefficient 1 as i and -1 as -i, and uses a + bi or a - bi when both terms are nonzero.

Function

complexNumberSummary(firstReal: int, firstImaginary: int, secondReal: int, secondImaginary: int) → String[]

Examples

Example 1

firstReal = 2firstImaginary = -1secondReal = -2secondImaginary = 1return = ["0","false","2 - i","-2 + i"]

The numbers cancel under addition but are not equal.

Constraints

  • All parts fit in signed 32-bit integers and their sums do too.

More Bloomberg LP Phone Screen questions

Similar questions at other companies

Bloomberg LP interview experiences

All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[] complexNumberSummary(int firstReal, int firstImaginary, int secondReal, int secondImaginary) {
      // Write your code here.
    }
}
Checking account…