Compute minimum time with task cooldowns
Company: Chime
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of constrained task scheduling, frequency-based reasoning, and algorithmic complexity within the Coding & Algorithms domain (task scheduling and combinatorial optimization), emphasizing both conceptual understanding and practical application.
Constraints
- 0 <= len(tasks) <= 100000
- Each task is an uppercase English letter from 'A' to 'Z'
- 0 <= c <= 100000
- Each task takes exactly 1 time unit
Examples
Input: (['A','A','A','B','B','B'], 2)
Expected Output: 8
Explanation: One optimal schedule is A, B, idle, A, B, idle, A, B. The total time is 8.
Input: (['A','A','A','B','B','C'], 2)
Expected Output: 7
Explanation: One optimal schedule is A, B, C, A, B, idle, A. The final A executions are separated by at least 2 time units.
Hints
- The task type with the highest frequency determines the minimum number of separated groups you may need.
- Think of arranging the most frequent tasks first, then filling the gaps with other tasks before deciding whether idle slots are necessary.