Pergunta de entrevista da empresa Morgan Stanley

package Interviews; /** * ===================Question=================== * In a college, A student can be identified uniquely with combination of student's first and last name * and in a given stream a student can enroll to one or many subjects. Finally, during evaluations students are scored for each subjects * * E.g. In Physics Subject(See code below) Rahul, Sidd, Monica has scored 40, 50, 30 marks each. * * * We need to print the students in the descending order of their average marks across subjects. * * Expected output for students in code snippet should be as below: * * Student{firstName='Sidd', lastName='Bhatia', age=30, stream='Science', avgScore=50.0} * Student{firstName='Neha', lastName='Jain', age=33, stream='Science', avgScore=48.0} * Student{firstName='Vishal', lastName='Garg', age=24, stream='Commerce', avgScore=44.0} * Student{firstName='Abhishek', lastName='Kakkar', age=22, stream='Commerce', avgScore=43.0} * Student{firstName='Rahul', lastName='Garg', age=25, stream='Science', avgScore=43.0} * Student{firstName='Monica', lastName='Mishra', age=26, stream='Science', avgScore=41.333333333333336} * * Also, please note Evaluator will give some different input to the program and code should produce expected output for the same. * ===========================Code snippet================================= */ import java.util.*; import java.util.stream.Collectors; public class AvgMaxGrade { static Map<String, List<Student>> subjectToStudentsMap = new HashMap(); static { subjectToStudentsMap.put("Physics", Arrays.asList( new Student("Rahul", "Garg", 25,"Science", 40), new Student("Sidd", "Bhatia", 30,"Science", 50), new Student("Monica", "Mishra", 26, "Science", 30) )); subjectToStudentsMap.put("Chemistry", Arrays.asList( new Student("Rahul", "Garg", 25,"Science", 46), new Student("Neha", "Jain", 33,"Science", 48), new Student("Monica", "Mishra", 26,"Science", 46) )); subjectToStudentsMap.put("Maths", Arrays.asList( new Student("Vishal", "Garg", 24,"Commerce", 44), new Student("Abhishek", "Kakkar",22, "Commerce", 43), new Student("Monica", "Mishra", 26,"Science", 48) )); } public static void main(String[] args) { //Write your code here } class Student implements Comparable { String firstName; String lastName; double score; String stream; int age; public Student(String firstName, String lastName, int age, String stream, double score) { this.firstName = firstName; this.lastName = lastName; this.score = score; this.age = age; this.stream = stream; } @Override public int compareTo(Object o) { Student s2 = (Student) o; return Double.compare(s2.score, this.score); } @Override public String toString() { return "Student{" + "firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + ", score=" + score + ", stream='" + stream + '\'' + ", age=" + age + '}'; } }

Resposta da entrevista

Sigiloso

12 de out. de 2022

Hello, what was the steps of the interview ? Only coding solving problems or also questions ?