## Symphony Services Interview Question for Applications Developers

Team: UI
Country: India
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
5
of 5 vote

int temp=1;
for(int i=0;i<size;i++)
temp*=b[i];
for(i=0;i<size;i++)
c[i]=a[i]*temp/b[i];
...............................O(n)

Comment hidden because of low score. Click to expand.
1
of 1 vote

``````int[] getArrayC(int[] a, int[] b) {

int i;
int product = 1;
int length = a.length();
for ( i = 0 ; i < n ; i++ ) {
product = product*b[i];
}

for ( i = 0 ; i < n ; i++ ) {
c[i] = a[i]*product/b[i];
}

return c;

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

hi there. if the length of the array is 3, then how can we get b[3]?

Comment hidden because of low score. Click to expand.
0

sorry its b[2] i made a mistake there

Comment hidden because of low score. Click to expand.
0

and another correction... the third equation is,
c[2] = a[2] * b[0] * b[1]

Comment hidden because of low score. Click to expand.
0
of 0 vote

Have two more arrays of size n.
X(i) = product of elements of B will i-1
Y(i) = product of elements of B from i+1 to n

these can be calulated in O(n)
now C(i) = A(i) * X(i) * Y(i)

Comment hidden because of low score. Click to expand.
0
of 0 vote

Simple loop just once from i =0 to 2 and keep maintaining values as
j= i+1 % 3 and k = i+2 % 3

Comment hidden because of low score. Click to expand.
0
of 0 vote

You can't get O(log n). It takes O(n) to just look at all the elements, which is necessary for answering this problem.

Comment hidden because of low score. Click to expand.
0

for(int i=0;i<3;i++)
{
c[i] = a[i] * b[ (i+1)%3 ] * b[ (i+2)%3 ]
}

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.