Compute distance to nearest taxi in grid | Google Interview Question