Pregunta de entrevista de MathWorks

Algorithm for connecting squares in a grid