Amazon Interview Question

The question was same as the one with code name course schedule in leetcode.