## Akamai Interview Question

Country: India
Interview Type: Phone Interview

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

Don't reinvent the wheel, put your data into a database and query your data using sql.

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

In scala i would use plain class list and filter function. Complexity is linear O(n)

``````type Exam = (String, Double)
val subjectToSearch = "Math"
val minimumPassing = 60.0
case class Student(val id: String, val name: String, val age: Int, val exams: List[Exam]) {
}

val students = List[Student](
Student("1", "1", 18, List(("English",20.34),("Math",84.5))),
Student("2", "1", 18, List(("English",30.34),("History",74.5))),
Student("3", "1", 18, List(("English",40.34),("History",64.5))),
Student("4", "1", 18, List(("English",50.34),("History",54.5))),
Student("5", "1", 18, List(("English",60.34),("Math",64.5))),
Student("6", "1", 18, List(("English",70.34),("Math",34.5))),
Student("7", "1", 18, List(("English",80.34),("History",24.5)))
)

students.filter(curStudent => curStudent.exams.filter(exam => exam._2>minimumPassing && exam._1.equalsIgnoreCase(subjectToSearch)).size > 0)``````

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

Create binary trees, one for each subject. The node contains a score, a set of students for that score, and children (which are nodes) for values below the score and above it.

``````class SubjectTree {

int score;

Set<Student> students = new Set<Student>();

SubjectTree lesser;
SubjectTree greater;

}``````

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

I'd go with Joe O's answer but I would add a hashtable to store each binary tree with the subject associated with it.

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.