Amazon interview question

Easy-medium leetcode, BFS/DFS questions, simple array