Amazon Interview Question

Algorithm leet code question (graphs)