@@ -132,9 +132,10 @@ int main() {
132
132
return 0;
133
133
}
134
134
</TabItem >
135
- <TabItem value =" java " label =" Java " >
136
- <SolutionAuthor name =" @Vipullakum007 " />
137
- import java.util.ArrayList;
135
+ ```
136
+ ### JAVA
137
+ ```<TabItem value="java" label="Java"> <SolutionAuthor name="@Vipullakum007"/>
138
+ import java.util.ArrayList;
138
139
import java.util.List;
139
140
140
141
public class SpiralMatrix {
@@ -185,8 +186,10 @@ public class SpiralMatrix {
185
186
}
186
187
}
187
188
</TabItem>
188
- <TabItem value =" python " label =" Python " >
189
- <SolutionAuthor name =" @Vipullakum007 " />
189
+ ```
190
+ ### Python
191
+
192
+ ``` <TabItem value="python" label="Python"><SolutionAuthor name="@Vipullakum007"/>
190
193
def spiralOrder(matrix):
191
194
if not matrix:
192
195
return []
@@ -228,15 +231,19 @@ matrix = [
228
231
print(spiralOrder(matrix)) # Output: [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]
229
232
230
233
</TabItem>
234
+ ```
231
235
</Tabs >
232
- Complexity Analysis
233
- Time Complexity: O(m * n)
234
- Reason: We visit every element in the matrix exactly once.
235
236
236
- Space Complexity: O(1)
237
- Reason: We only use a fixed amount of extra space, regardless of the input size.
238
- References
239
- LeetCode Problem: Spiral Matrix
237
+ ### Complexity Analysis
238
+ #### Time Complexity: O(m * n)
239
+ ** Reason:** We visit every element in the matrix exactly once.
240
+
241
+ ** Space Complexity:** O(1)
242
+ ** Reason:** We only use a fixed amount of extra space, regardless of the input size.
243
+ ### References
244
+ ** LeetCode Problem:** Spiral Matrix
240
245
241
- Author's LeetCode Profile: Vipul Lakum
246
+ ** Author's LeetCode Profile:** Vipul Lakum
242
247
```
248
+
249
+
0 commit comments