Skip to content

Commit 9811a31

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

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

scheduling/interval_scheduling_algorithm.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@
55
66
"""
77

8+
89
def interval_scheduling(stimes, ftimes):
910
index = list(range(len(stimes)))
1011
# sort according to finish times
1112
index.sort(key=lambda i: ftimes[i])
12-
13+
1314
maximal_set = set()
1415
prev_finish_time = 0
1516
for i in index:
1617
if stimes[i] >= prev_finish_time:
1718
maximal_set.add(i)
1819
prev_finish_time = ftimes[i]
19-
20+
2021
return maximal_set
21-
22-
23-
n = int(input('Enter number of activities: '))
24-
stimes = input('Enter the start time of the {} activities in order: '
25-
.format(n)).split()
22+
23+
24+
n = int(input("Enter number of activities: "))
25+
stimes = input("Enter the start time of the {} activities in order: ".format(n)).split()
2626
stimes = [int(st) for st in stimes]
27-
ftimes = input('Enter the finish times of the {} activities in order: '
28-
.format(n)).split()
27+
ftimes = input(
28+
"Enter the finish times of the {} activities in order: ".format(n)
29+
).split()
2930
ftimes = [int(ft) for ft in ftimes]
30-
31+
3132
ans = interval_scheduling(stimes, ftimes)
32-
print('A maximum-size subset of activities that are mutually compatible is', ans)
33+
print("A maximum-size subset of activities that are mutually compatible is", ans)

0 commit comments

Comments
 (0)