Coupang Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Phone Interview
void printArrayMultiplicationBI(int[] array) {
BigInteger multiplication = new BigInteger("1");
for (int a : array) {
multiplication = multiplication.multiply(new BigInteger(Integer.toString(a)));
}
for (int a : array) {
System.out.print(multiplication.divide(new BigInteger(Integer.toString(a)))+" ");
}
}
Forced to give downvote to all. Think about it. What you are going to do when we have 0's lets say? One zero?
- NoOne April 22, 2017input: [1 2 0 5 6]
output: [ 0 0 60 0 0 ]
Hmm.
That was the trick all along.