Amazon interview question

Leetcode medium level arrays and graph traversal