Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f30aec

Browse files
Create 1235.py
1 parent 19a0c03 commit 1f30aec

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎1001-1500/1235.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def jobScheduling(self, startTime: List[int], endTime: List[int], profit: List[int]) -> int:
3+
ind = 0
4+
for e, s, p in sorted(zip(endTime, startTime, profit)):
5+
startTime[ind] = s
6+
endTime[ind] = e
7+
profit[ind] = p
8+
ind += 1
9+
10+
for i in range(1, len(profit)):
11+
12+
index = bisect_right(endTime, startTime[i]) - 1
13+
profit[i] = max(profit[i - 1], (profit[index] if index >= 0 else 0) + profit[i])
14+
15+
return profit[-1]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /