Skip to content

Commit 0aa46a0

Browse files
Update job_scheduling.py
1 parent e9d90ee commit 0aa46a0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

dynamic_programming/job_scheduling.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
"""
77

88
from bisect import bisect_right
9-
from typing import List, Tuple
109

1110

12-
def job_scheduling(jobs: List[Tuple[int, int, int]]) -> int:
11+
def job_scheduling(jobs: list[tuple[int, int, int]]) -> int:
1312
"""
1413
>>> jobs = [(1, 3, 50), (3, 5, 20), (0, 6, 100), (4, 6, 70), (3, 8, 60)]
1514
>>> job_scheduling(jobs)
@@ -29,8 +28,7 @@ def job_scheduling(jobs: List[Tuple[int, int, int]]) -> int:
2928

3029
for i in range(1, n):
3130
profit_incl = jobs[i][2]
32-
# ✅ allow jobs that start when another ends
33-
index = bisect_right(end_times, jobs[i][0]) - 1
31+
index = bisect_right(end_times, jobs[i][0]) - 1 # allow adjacent jobs
3432
if index != -1:
3533
profit_incl += dp[index]
3634
dp[i] = max(profit_incl, dp[i - 1])

0 commit comments

Comments
 (0)