Magic Leap Interview Question

A leetcode question about matrix and dfs.