Movatterモバイル変換


[0]ホーム

URL:


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

Commit5205538

Browse files
author
haotf
committed
feat: 规划兼职工作
1 parent29010b0 commit5205538

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

‎1235.规划兼职工作.java‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* @lc app=leetcode.cn id=1235 lang=java
3+
*
4+
* [1235] 规划兼职工作
5+
*/
6+
7+
// @lc code=start
8+
classSolution {
9+
privatestaticintmax =0;
10+
11+
publicintjobScheduling(int[]startTime,int[]endTime,int[]profit) {
12+
backtrack(0,0,startTime,endTime,profit);
13+
returnmax;
14+
}
15+
16+
privatestaticvoidbacktrack(intstart,intres,int[]startTime,int[]endTime,int[]profit) {
17+
intlength =startTime.length;
18+
if (start >=length) {
19+
max =Math.max(max,res);
20+
return;
21+
}
22+
for (inti =start;i <length;i++) {
23+
intright =endTime[i];
24+
intnext =i +1;
25+
while (next <length &&startTime[next] <right) {
26+
next++;
27+
}
28+
res +=profit[i];
29+
backtrack(next,res,startTime,endTime,profit);
30+
res -=profit[i];
31+
}
32+
}
33+
}
34+
// @lc code=end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp