Pregunta de entrevista de Clear Street

Machine coding round involving a grid