Domanda di colloquio di Amazon

First question was leetcode medium involving graphs