Algorithm/DS Problem#7: Task Scheduler keeping the order intact
This problem is a variation of LeetCode#621. Task Scheduler. Main difference is, all the tasks needed to be executed in order.
P.S. #Facebook interview question
Problem Statement:
Given a array of tasks
, representing the tasks a robot needs to run and the cooldown interval, output the minimum number of time slots required to run them. The tasks should be processed in the same order.
cooldown represents the cooldown period between two same tasks (the same letter in the array), that is that there must be at least cooldown units of time between any two same tasks.
Input
tasks=[‘A’,’A’,’B’, ‘C’,’B’]
cooldown=3
Output
10
Explanation:
Order is : A _ _ _ A B C _ _ B