Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
First, generate an m x n matrix filled with -1s.
Navigate within the matrix at (i, j) with the help of a direction vector ⟨di, dj⟩. At (i, j), you need to decide if you can keep going in the current direction.
If you cannot keep going, rotate the direction vector clockwise by 90 degrees.