Question d’entretien chez Amazon

Leet code question similar to course schedule II.