Cruise interview question

Unique Paths III from leetcode