leetcode-621-Task Scheduler

本文探讨了任务调度算法中关于最大字符出现频率的问题,提出了一种使用优先级队列的解决方案。通过存储每个字符出现的次数,将时间间隔视为时间槽,并尝试填充任务到这些槽中,最终计算出总的空闲时间加上任务大小。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Error:
do not know how to do: Actually I know part of answer, but do not think it thoroughly.

In here, we have two cases: mainly of max. char or not mainly of max. char.

ideally, the answer is idle + total of task

so it need to know how many idle in it. which we get (max. - 1) * n empty position and fill remain alpha in it, if idle >= 0 than output idle + task.size(), otherwise output task.size()


use priority_queue to do this:
1. store the times of each character occur.
2. treat each intervals as the time slots, try to fill the task into the slots.
3. accumulate the time

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值