Start the staircase at the top-right.
transcript
Rows rise. Columns rise. But no single line exists. Pick a corner to start. One corner works. Let me show you which one.
Look for two. From the top-left, both neighbours are larger. So the walk goes the wrong way. From the top-right, the choice is clear. Always test this grid by hand.
If the cell is above the target, go left. If it is below the target, go down. If it is equal, you are done. Each step drops a whole line. Check a target in the first column. That case breaks many solutions.
Five hundred by five hundred. At most rows plus columns minus one. That is nine hundred ninety-nine steps. A scan of every cell would need two hundred fifty thousand.
This tool walks. It does not halve. That cost is the right one here. A flat search needs one sorted line.
Choose the corner with care. Larger, go left. Smaller, go down. Test a target in the first column. Full breakdown in the lecture.