Amazon interview question

First question was leetcode medium involving graphs