Pregunta de entrevista de Waymo

Solve a grid based C++ question