Nutanix Interview Question

A matrix problem that could be approached with DP or BFS.