Amazon interview question

A leetcode question using DFS to solve and 2LP questions.