2
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:3
col, row = len(matrix[0]), len(matrix)4
l, t, r, b = 0, 0, col - 1, row - 16
while l <= r and t <= b:8
res.append(matrix[t][i])10
res.append(matrix[i][r])12
# Append the orphan left by the open interval14
res.append(matrix[t][r])16
# From right to left at the bottom17
for i in range(r, l, -1):18
res.append(matrix[b][i])20
# Avoid duplicated appending if it is a square22
res.append(matrix[b][r])24
# From bottom to top at the left25
for i in range(b, t, -1):26
res.append(matrix[i][l])