Skip to content

Commit fa68f43

Browse files
committed
Merge remote-tracking branch 'origin-tan/main' into main-tan
2 parents 0b9e2d6 + 65f20f3 commit fa68f43

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

medium/885. Spiral Matrix III/solution-php.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ https://leetcode.com/problems/spiral-matrix-iii/solutions/5606322/solution-beat-
44

55
# Intuition
66
<!-- Describe your first thoughts on how to solve this problem. -->
7-
- To traverse all the cells in a grid of size `rows * cols` starting from a specific position (`rStart`, `cStart`) in a spiral order, we can use an array of directions and a variable to keep track of the number of steps needed in each direction.
7+
- To traverse all the cells in a grid of size `rows * cols` starting from a specific position (`rStart`, `cStart`) in spiral order, we can use an array of directions and a variable to keep track of the number of steps needed in each direction.
88
- We will move in sequential directions: **right, down, left, and up**, increasing the number of steps after every two directions (one complete cycle).
99

1010
# Approach
@@ -17,11 +17,11 @@ https://leetcode.com/problems/spiral-matrix-iii/solutions/5606322/solution-beat-
1717
- After every two directions, increment the number of steps required.
1818

1919
# Complexity
20-
- Time complexity: **O(n×m)**
20+
- Time complexity: $O(n \times m)$
2121

2222
We will traverse all cells in the grid once, so the time complexity is linear with respect to the number of cells in the grid, or `O(n×m)`, where `n` is the number of rows and `m` is the number of columns.
2323

24-
- Space complexity: **O(n×m)**
24+
- Space complexity: $O(n \times m)$
2525

2626
The result array `ans` will contain all positions of the grid, so the space complexity is also linear with respect to the number of cells in the grid, or `O(n×m)`.
2727

@@ -63,3 +63,5 @@ class Solution
6363
}
6464

6565
```
66+
67+
If it can help you, please give me an upvote. Thank you so much for reading!

0 commit comments

Comments
 (0)