## Amdocs Interview Question for Developer Program Engineers

Country: United States
Interview Type: Written Test

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

Isn't this an np hard problem?

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

Here is the algo
1. Find average for whole array
2. Now start with first element and parse through array. Find average so far stop if equal.
3. return the index;

Code Below:

``````int findEqualAverage(int[] A){
int sum = 0;
for(int i=0;i<A.length;i++){
sum += A[i];
}
float average  = (float)sum/(float)A.length;
sum = 0;
for(int i=0;i<A.length;i++){
sum+=A[i];
float averageSofar = ((float)sum)/(i+1);
if(averageSofar == average)
return (i+1);
}

}``````

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

This won't work as expected in strictly increasing or descending arrays.
At least do a randomize before parse through, but even this won't guarantee a result.
Consider 1,1,1,1,1,1,1,1,1,1,-10.

Comment hidden because of low score. Click to expand.
-2
of 2 vote

balanced partitioning problem

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

No..we dont need to equate only the sums..there is also a /n factor in average..
if 3 elements and 8 elements have equal sum in an array of 11 elements, their avg wont be equal.

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.