J.P. Morgan Interview Question

A recursion problem on 2-dimensional grid(matrix) traversal.