Google Interview Question for Software Engineer / Developers


Country: United States




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

That sounds like homework, not an interview question..

- Miguel Oliveira October 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

The articles might be an understatement.
And remember the discussion about "illusion" ? That includes mechanisms of "work transfer."

- S O U N D W A V E October 09, 2013 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

sivaji8, stop tagging these stupid posts as Google Interview questions. If you want help on your homework, go to stackoverflow.com.

- Alistair October 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class Student
{
	String id;
	ArrayList<Double> scores;
	Map<String, ArrayList<Double>> mapScores;
	Map<String, Double> map;
	public Student(String id)
	{
		this.id = id;
		scores = new ArrayList<Double>();
		mapScores = new HashMap<String, ArrayList<Double>>();
		map = new HashMap<String, Double>();
	}
	
	public void addScore(double score)
	{
		scores.add(score);
		
		setStudentScores();
	}
	
	public void setStudentScores()
	{
		mapScores.put(id, scores);
	}
	
	public Map<String, ArrayList<Double>> getStudentScores()
	{				
		return mapScores;
	}
	
	public void averageScore()
	{
		//if(!mapScores.containsKey(id))
		ArrayList<Double> scores = mapScores.get(id);		
		//System.out.println(scores);
		Collections.sort(scores);
		//System.out.println(scores);
		
		double sum = 0;
		
		for(int i = scores.size() - 1; i >= scores.size() - 5; i--)
			sum += scores.get(i);
		
		double average = sum / 5.0;
		
		map.put(id, average);
	}
	
	public Map<String, Double> getAverageScore()
	{
		averageScore();
		return map;
	}
}

public class StudentScores 
{
	public static void main(String[] args)
	{
		Student student1 = new Student("1");
		
		student1.addScore(80);
		student1.addScore(100);
		student1.addScore(90);
		student1.addScore(70);
		student1.addScore(50);
		student1.addScore(60);
		student1.addScore(85);
		student1.addScore(95);
		student1.addScore(82);
		student1.addScore(78);
		student1.addScore(88);
		student1.addScore(96);
		
		System.out.println(student1.getAverageScore().toString());
	}		
}

- Anonymous October 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I got the exact same question in my amazon interview.

- chopin October 31, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

n*logn + n

- nkpangcong October 09, 2013 | Flag Reply


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