Amazon Interview Question

Typical algorithm problems about array and DFS/BFS