#455 Average Age of Top Students

Companies:
Innotech
Themes:
JavaStreams & LambdasPractice

Calculate the average age of the top n students. Invalid strings may be provided in age and avg.

/**
 * public class Student {
 *     public String name; // name
 *     public String age; // age is a number such as "30", "54".
 *     public String avg; // average grade is a floating-point number such as "4.6", "1.0". Grade range is from "1.0" to "5.0".
 * }
 */
public class StudentUtils {

    // Calculate the average age of the top n students.
    public static double foo(List<Student> students, int n) {
        ...
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in