You are given a list of calls, where each call has a type such as search, tts, or db.lookup. Each call type has a cooldown period. There are m time slots and two lanes. In one time slot, you may start at most one call per lane. The same call type cannot be started again until its cooldown has passed.
Return an optimal schedule that starts the calls as early as possible while respecting the cooldown rules.
Example:
calls = ["search", "tts", "search", "db.lookup", "search"]
cooldown = {"search": 2}
m = 2
One optimal schedule by time slot (two lanes):
t=0: startsearch,ttst=1: startdb.lookupt=3: startsearcht=6: startsearch
这道题考察的是带冷却时间的任务调度:每种调用类型在启动后需要等待指定的 cooldown 才能再次出现,同时每个时间槽有两条 lane,可并行启动最多两个不同调用。解题时通常需要维护每个任务类型的下一次可执行时间,并结合优先队列、哈希表或贪心策略,尽量把当前可执行的任务往最早的时间槽里安排。核心难点在于既要满足同类任务间隔限制,又要利用双通道提高吞吐率,避免因为局部选择不当导致整体完成时间变长。