Pregunta de entrevista de Peak

Interviewer asked me one DSA question on spirally traversing matrix