Skip to content

Commit 7c7f32d

Browse files
Solve : Spiral Matrix
1 parent f6cb1d9 commit 7c7f32d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

spiral-matrix/printjin-gmailcom.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def spiralOrder(self, matrix):
3+
result = []
4+
while matrix:
5+
result += matrix.pop(0)
6+
if matrix and matrix[0]:
7+
for row in matrix:
8+
result.append(row.pop())
9+
if matrix:
10+
result += matrix.pop()[::-1]
11+
if matrix and matrix[0]:
12+
for row in matrix[::-1]:
13+
result.append(row.pop(0))
14+
return result

0 commit comments

Comments
 (0)