Cruise Interview Question

Unique Paths III from leetcode