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?

- Nick December 05, 2013 | Flag Reply
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);
}

	
}

- loveCoding December 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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.

- gameboy1024 December 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
-2
of 2 vote

balanced partitioning problem

- thelineofcode December 05, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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.

- alex December 12, 2013 | 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