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]
'코딩 테스트 및 알고리즘 > leetcode for google' 카테고리의 다른 글
leetcode hard : Stamping The Sequence (0) | 2022.11.04 |
---|---|
leetcode medium : Maximum Length of a Concatenated String with Unique Characters (0) | 2022.10.29 |
leetcode medium : Using a Robot to Print the Lexicographically Smallest String (0) | 2022.10.14 |
leetcode hard : Paths in Matrix Whose Sum Is Divisible by K (0) | 2022.10.14 |
Substring with largest variance (0) | 2022.10.14 |