Amazon interview question

Typical algorithm problems about array and DFS/BFS