Bird
Raised Fist0

Given the final minimum time output of 7 for the Task Scheduler with cooldown n=2, and tasks ['A','A','A','B','B','C'], which task frequency distribution most likely produced this result?

hard🔄 Reverse Engineer Q9 of Q15
Greedy Algorithms - Task Scheduler (CPU Cooling)
Given the final minimum time output of 7 for the Task Scheduler with cooldown n=2, and tasks ['A','A','A','B','B','C'], which task frequency distribution most likely produced this result?
A{'A': 2, 'B': 2, 'C': 2}
B{'A': 3, 'B': 3, 'C': 1}
C{'A': 3, 'B': 2, 'C': 1}
D{'A': 4, 'B': 1, 'C': 1}
Step-by-Step Solution
Solution:
  1. Step 1: Analyze max frequency and counts

    Output 7 implies max_freq=3 with max_count=1 (task 'A').
  2. Step 2: Match frequency distribution

    {'A': 3, 'B': 2, 'C': 1} has max_freq=3 and max_count=1, cooldown n=2, so minimum time = max((3-1)*(2+1)+1, total tasks) = max(7,6) = 7.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Frequency matches output time formula [OK]
Quick Trick: Use formula with max_freq and max_count to reverse engineer [OK]
Common Mistakes:
MISTAKES
  • Ignoring multiple max frequency tasks
  • Misapplying formula
Trap Explanation:
PITFALL
  • Candidates often pick distributions with multiple max frequency tasks inconsistent with output.
Interviewer Note:
CONTEXT
  • Tests deep understanding of frequency-based formula and reverse reasoning
Master "Task Scheduler (CPU Cooling)" in Greedy Algorithms

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Greedy Algorithms Quizzes