---
# System prepended metadata

title: 2432. The Employee That Worked on the Longest Task
tags: [Leetcode, Easy]

---

# 2432. The Employee That Worked on the Longest Task
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/description/
## Code
```java=
class Solution {
    public int hardestWorker(int n, int[][] logs) {
        int maxTime = 0, ans = -1;
        int prev = 0;
        for(int[] log:logs){
            int time = log[1]-prev;
            if(maxTime<time || (maxTime==time&&ans>log[0])){
                maxTime = time;
                ans = log[0];
            }
            prev = log[1];
        }
        return ans;
    }
}
```