comefrom: <doocs>0054.Spiral Matrix_1.py
code: def spiralOrder( matrix: List[List[int]]) -> List[int]:
      m, n = len(matrix), len(matrix[0])
      ans = []
      top, bottom, left, right = 0, m - 1, 0, n - 1
      while left <= right and top <= bottom:
          ans.extend([matrix[top][j] for j in range(left, right + 1)])
          ans.extend([matrix[i][right] for i in range(top + 1, bottom + 1)])
          if left < right and top < bottom:
              ans.extend([matrix[bottom][j] for j in range(right - 1, left - 1, -1)])
              ans.extend([matrix[i][left] for i in range(bottom - 1, top, -1)])
          top, bottom, left, right = top + 1, bottom - 1, left + 1, right - 1
      return ans
masked: def sample_funcname ( var_0 : List [ List [ int ] ] ) -> List [ int ] :
      var_1 , var_2 = len ( var_0 ) , len ( var_0 [ 0 ] )
      var_3 = [ ]
      var_4 , var_5 , var_6 , var_7 = 0 , var_1 - 1 , 0 , var_2 - 1
      while var_6 <= var_7 and var_4 <= var_5 :
          var_3.extend ( [ var_0 [ var_4 ] [ var_8 ] for var_8 in range ( var_6 , var_7 + 1 ) ] )
          var_3.extend ( [ var_0 [ var_9 ] [ var_7 ] for var_9 in range ( var_4 + 1 , var_5 + 1 ) ] )
          if var_6 < var_7 and var_4 < var_5 :
              var_3.extend ( [ var_0 [ var_5 ] [ var_8 ] for var_8 in range ( var_7 - 1 , var_6 - 1 , - 1 ) ] )
              var_3.extend ( [ var_0 [ var_9 ] [ var_6 ] for var_9 in range ( var_5 - 1 , var_4 , - 1 ) ] )
          var_4 , var_5 , var_6 , var_7 = var_4 + 1 , var_5 - 1 , var_6 + 1 , var_7 - 1
      return var_3
  