Skip to content

Commit 856181d

Browse files
committed
增加注释
1 parent eb7905b commit 856181d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main/java/com/diguage/algo/leetcode/_0621_TaskScheduler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public int leastInterval(char[] tasks, int n) {
3131
}
3232
Arrays.sort(counts);
3333
int maxCount = counts[25];
34+
// 前面 maxCount - 1 个任务需要有 n 个间隔,所以就是 (maxCount - 1) * (n + 1)
35+
// 而最后一个任务不需要间隔,就只能算 1
3436
int restCount = (maxCount - 1) * (n + 1) + 1;
3537
for (int i = 24; i >= 0 && counts[i] == maxCount; i--) {
3638
restCount++;

0 commit comments

Comments
 (0)