The Employee That Worked on the Longest Task Problem
The Employee That Worked on the Longest Task Problem — ExecCode Easy DSA Practice
Solve the The Employee That Worked on the Longest Task problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a 2D integer array logs where logs[i] = [idi, leaveTimei] where:. Your task is to compute the required answer and return the id of the employee that worked the task with the longest time. There are n employees, each with a unique id from 0 to n - 1. - idi is the id of the employee that worked on the i^th task, and - leaveTimei is the time at which the employee finished the i^th task. All the values leaveTime_i are unique.
Examples
Input {"n": 10, "logs": [[0, 3], [2, 5], [0, 9], [1, 15]]}; Output 1. Input {"n": 26, "logs": [[1, 1], [3, 7], [2, 12], [7, 17]]}; Output 3
Constraints
2 <= n <= 500 1 <= logs.length <= 500 logs[i].length == 2 0 <= idi <= n - 1 1 <= leaveTimei <= 500 idi != idi+1 leaveTime_i are sorted in a strictly increasing order.
Practice The Employee That Worked on the Longest Task free on ExecCode. Browse DSA problems, topic map, and placement guides.