TuSimple Interview Question

Traversing an NxN matrix question.