Compute minimum escape time in a grid | Snapchat Interview Question