You have a table with N rows and M columns.
In a single move, you can go from your current cell to a horizontally or vertically adjacent cell.
Moving up from an uppermost cell moves you to the corresponding bottommost cell.
Moving down from a bottommost cell moves you to the corresponding uppermost cell.
Moving left from a leftmost cell moves you to the corresponding rightmost cell.
Moving right from a rightmost cell moves you to the corresponding leftmost cell.
You are currently in the cell at row r1, column c1. Return the minimum number of moves required to get to the cell at row r2, column c2. All indices are 0-based.
|