O59

Task Scheduler (CPU Cooldown)

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: NUMERIC

Problem Statement & Objective

Given a characters array tasks and non-negative integer n representing CPU cooldown, return the minimum number of intervals required to complete all tasks.

Function Signature (Python)

task_scheduler_cpu_cooldown(tasks: list[str], n: int) -> int

Input & Output Contract

Output Rule:Minimum toplam zaman birimi.

System Constraints

1 <= gorevler.length <= 10^4
gorevler[i] büyük İngilizce harftir
0 <= n <= 100

Example Execution Walkthrough

gorevler = ['A','A','A','B','B','B'], n = 2
A -> B -> idle -> A -> B -> idle -> A -> B -> toplam 8 birim

Example Test Scenarios (3)

Example 1
Input:[["A","A","A","B","B","B"],2]
Expected Output:8
Example 2: n=0
Input:[["A","A","A","B","B","B"],0]
Expected Output:6
Example 3
Input:[["A","A","A","A","B","B","C"],2]
Expected Output:10
Loading Python Editor...
Input Parameters
[
  [
    "A",
    "A",
    "A",
    "B",
    "B",
    "B"
  ],
  2
]
Expected Output
8