Compute longest rising path in a grid | Meta Interview Question