parameters: (self, matrix)
return_statement: return dp
docstring: :type matrix: List[List[int]]
          :rtype: List[List[int]]
docstring_summary: :type matrix: List[List[int]]
          :rtype: List[List[int]]
docstring_tokens: : type matrix : List [ List [ int ]] : rtype : List [ List [ int ]]
function: def updateMatrix(self, matrix):
          """
          :type matrix: List[List[int]]
          :rtype: List[List[int]]
          """
          dp = [[float("inf")]*len(matrix[0]) for _ in xrange(len(matrix))]
          for i in xrange(len(matrix)):
              for j in xrange(len(matrix[i])):
                  if matrix[i][j] == 0:
                      dp[i][j] = 0
                  else:
                      if i > 0:
                          dp[i][j] = min(dp[i][j], dp[i-1][j]+1)
                      if j > 0:
                          dp[i][j] = min(dp[i][j], dp[i][j-1]+1)
          for i in reversed(xrange(len(matrix))):
              for j in reversed(xrange(len(matrix[i]))):
                  if matrix[i][j] == 0:
                      dp[i][j] = 0
                  else:
                      if i < len(matrix)-1:
                          dp[i][j] = min(dp[i][j], dp[i+1][j]+1)
                      if j < len(matrix[i])-1:
                          dp[i][j] = min(dp[i][j], dp[i][j+1]+1)
          return dp
function_tokens: def updateMatrix ( self , matrix ) : dp = [ [ float ( "inf" ) ] * len ( matrix [ 0 ] ) for _ in xrange ( len ( matrix ) ) ] for i in xrange ( len ( matrix ) ) : for j in xrange ( len ( matrix [ i ] ) ) : if matrix [ i ] [ j ] == 0 : dp [ i ] [ j ] = 0 else : if i > 0 : dp [ i ] [ j ] = min ( dp [ i ] [ j ] , dp [ i - 1 ] [ j ] + 1 ) if j > 0 : dp [ i ] [ j ] = min ( dp [ i ] [ j ] , dp [ i ] [ j - 1 ] + 1 ) for i in reversed ( xrange ( len ( matrix ) ) ) : for j in reversed ( xrange ( len ( matrix [ i ] ) ) ) : if matrix [ i ] [ j ] == 0 : dp [ i ] [ j ] = 0 else : if i < len ( matrix ) - 1 : dp [ i ] [ j ] = min ( dp [ i ] [ j ] , dp [ i + 1 ] [ j ] + 1 ) if j < len ( matrix [ i ] ) - 1 : dp [ i ] [ j ] = min ( dp [ i ] [ j ] , dp [ i ] [ j + 1 ] + 1 ) return dp