Amazon | AWS | SDE2 role
Anonymous User
885
May 11, 2026
May 11, 2026

Hi,
This was the question asked to me today in AWS phone screen round :
You are given n tasks. Each task has:

A type (string/character)
A list of dependencies (other tasks that must finish first)

Rules:

Each task takes 1 unit of time to execute.
Tasks of the same type must be separated by a cooldown of k units (i.e., after executing a task of type X at time t, the next task of type X can only run at time ≥ t + k + 1).
A task is ready only after all its dependencies have completed.
If no task is ready or all ready tasks are blocked by cooldown, time advances (idle).

Find the minimum time to complete all the tasks.

example :
{t1 -> "A",
t2->"A",
t3->"B",
t4->"A",
t5->"B"}
dependencies : {[t3,t1], [t4, t2]}
cooldown : 2

result : 7

Comments (4)