Skip to content

Commit 34c7ecd

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 147c3ac commit 34c7ecd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dynamic_programming/job_scheduling.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from bisect import bisect_right
88

9+
910
def job_scheduling(jobs):
1011
"""
1112
>>> jobs = [(1, 3, 50), (3, 5, 20), (0, 6, 100), (4, 6, 70), (3, 8, 60)]
@@ -28,13 +29,14 @@ def job_scheduling(jobs):
2829
for i in range(1, n):
2930
profit_incl = jobs[i][2]
3031
# Find last non-conflicting job using binary search
31-
index = bisect_right(end_times, jobs[i][0]-1) - 1
32+
index = bisect_right(end_times, jobs[i][0] - 1) - 1
3233
if index != -1:
3334
profit_incl += dp[index]
34-
dp[i] = max(profit_incl, dp[i-1])
35+
dp[i] = max(profit_incl, dp[i - 1])
3536
return dp[-1]
3637

3738

3839
if __name__ == "__main__":
3940
import doctest
41+
4042
doctest.testmod()

0 commit comments

Comments
 (0)