Skip to content

Commit 75b4648

Browse files
committed
Added Python solution for "The Employee That Worked on the Longest Task"
1 parent 90225f5 commit 75b4648

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
"""
6+
Time: O(n)
7+
Memory: O(1)
8+
"""
9+
10+
def hardestWorker(self, n: int, logs: List[List[int]]) -> int:
11+
best_id = best_time = start = 0
12+
13+
for emp_id, end in logs:
14+
time = end - start
15+
if time > best_time or (time == best_time and best_id > emp_id):
16+
best_id = emp_id
17+
best_time = time
18+
start = end
19+
20+
return best_id
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)