Complete the code to initialize the starting row index for spiral traversal.
int top = [1];The top row index starts at 0 because matrix indexing begins at 0.
Complete the code to initialize the ending column index for spiral traversal.
int right = [1] - 1;
The right column index is the number of columns minus one, so we use matrix[0].Length - 1.
Fix the error in the loop condition to traverse the top row from left to right.
for (int i = left; i [1]= right; i++) { result.Add(matrix[top][i]); }
The loop should run while i is less than or equal to right to include the last column.
Fill both blanks to traverse the right column from top to bottom.
for (int i = [1]; i [2]= bottom; i++) { result.Add(matrix[i][right]); }
Start from the row below top (top + 1) and go up to bottom inclusive (i <= bottom).
Fill all three blanks to traverse the bottom row from right to left.
for (int i = [1]; i [2] [3]; i--) { result.Add(matrix[bottom][i]); }
Start from right - 1, go while i is greater than or equal to left, decrement i each time.
