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)

- TABREZ October 02, 2012 | Flag Reply
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;

}

- belligerentCoder October 11, 2012 | Flag Reply
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]?

- Cod October 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

sorry its b[2] i made a mistake there

- abilash.s.90 October 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- abilash.s.90 October 02, 2012 | Flag
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)

- Anonymous October 02, 2012 | Flag Reply
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

- Ayisha October 02, 2012 | Flag Reply
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.

- Anonymous October 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- seawaman October 02, 2012 | Flag


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More