https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/

 

 

class Solution:
    def hardestWorker(self, n: int, logs: List[List[int]]) -> int:
        last = 0
        answer = [0,0]
		
        for _id, leave in logs:
            if leave - last > answer[0]:
                answer = [leave - last, _id]
            if leave - last == answer[0] and _id < answer[1]:
                answer[1] = _id
            last = leave

        return answer[1]

+ Recent posts