TuSimple interview question

Traversing an NxN matrix question.