Answer: ROLLS-ROYCE Hiring Challenge | Online Interview Question | Off-Campus OA (2024)
Answer · Posted Jun 2026
Approach Use a TreeMap to store each employee's total working time. Traverse every event. Compute the duration as: duration = outTime - inTime Add the duration to the corresponding employee's total. Since TreeMap stores keys in sorted order, the output is automatically sorted by employee ID. Convert the map into a 2D array. Strategy Create a TreeMap<Integer, Integer>. Traverse all attendance records. Calculate outTime - inTime. Add the duration to the employee's accumulated time. Store the final values into a ...
The full answer & interview discussion are available to premium members.
Log in Create a free account