Diagonal Traverse
Signals to notice
Brute force first
No simpler alternative — traversal IS the task. The challenge is getting the boundary logic right. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
The key insight
Iterate through 2*(m+n-1)-1 diagonals. Odd diagonals go up-right, even go down-left (or vice versa). For each diagonal, compute start position and traverse until out of bounds. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
What must stay true
There are m+n-1 diagonals. Elements on the same diagonal share the property that row+col is constant. The direction alternates with each diagonal. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Easy way to go wrong
Getting the starting position wrong for each diagonal — when going up-right, start from the bottom-left of the diagonal. When going down-left, start from the top-right. The fix is usually to return to the meaning of each move, not just the steps themselves.