Skip to content

Commit 85117f6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c11743e commit 85117f6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scheduling/weighted_interval_scheduling.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Implementation of Weighted Interval Scheduling algorithm
2-
# In this algorithm, we are given a list of jobs with start and end times,
2+
# In this algorithm, we are given a list of jobs with start and end times,
33
# and each job has a specific weight.
44
# The goal is to find the maximum weight subset of non-overlapping jobs.
55
# https://en.wikipedia.org/wiki/Interval_scheduling
@@ -9,11 +9,11 @@
99

1010
def latest_non_conflict(jobs: list[tuple[int, int, int]], n: int) -> int:
1111
"""
12-
This function finds the latest job that does not conflict with
12+
This function finds the latest job that does not conflict with
1313
the current job at index `n`.
14-
The jobs are given as (start_time, end_time, weight), and the
14+
The jobs are given as (start_time, end_time, weight), and the
1515
jobs should be sorted by end time.
16-
It returns the index of the latest job that finishes before the
16+
It returns the index of the latest job that finishes before the
1717
current job starts.
1818
Return: The index of the latest non-conflicting job.
1919
>>> latest_non_conflict([(1, 3, 50), (2, 5, 20), (4, 6, 30)], 2)
@@ -29,10 +29,10 @@ def latest_non_conflict(jobs: list[tuple[int, int, int]], n: int) -> int:
2929

3030
def find_max_weight(jobs: list[tuple[int, int, int]]) -> int:
3131
"""
32-
This function calculates the maximum weight of non-overlapping jobs
32+
This function calculates the maximum weight of non-overlapping jobs
3333
using dynamic programming.
3434
Each job is represented by a tuple (start_time, end_time, weight).
35-
The function builds a DP table where each entry `dp[i]` represents
35+
The function builds a DP table where each entry `dp[i]` represents
3636
the maximum weight achievable
3737
using jobs from index 0 to i.
3838
Return: The maximum achievable weight without overlapping jobs.
@@ -58,7 +58,7 @@ def find_max_weight(jobs: list[tuple[int, int, int]]) -> int:
5858
if latest_job != -1:
5959
include_weight += dp[latest_job]
6060

61-
# Exclude the current job, and take the maximum of including or
61+
# Exclude the current job, and take the maximum of including or
6262
# excluding
6363
dp[i] = max(include_weight, dp[i - 1])
6464

0 commit comments

Comments
 (0)