CloudKaptan interview question

Java array, 2d questions on traversal