Pergunta de entrevista da empresa Citadel Securities

A problem on travelling across a grid.