parameters: (self, heights)
return_statement: return left
docstring: :type heights: List[List[int]]
          :rtype: int
docstring_summary: :type heights: List[List[int]]
          :rtype: int
docstring_tokens: : type heights : List [ List [ int ]] : rtype : int
function: def minimumEffortPath(self, heights):
          """
          :type heights: List[List[int]]
          :rtype: int
          """
          directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
          def check(heights, x):
              lookup = [[False]*len(heights[0]) for _ in xrange(len(heights))]
              q = collections.deque([(0, 0)])
              while q:
                  r, c = q.popleft()
                  if (r, c) == (len(heights)-1, len(heights[0])-1):
                      return True
                  for dr, dc in directions:
                      nr, nc = r+dr, c+dc
                      if not (0 <= nr < len(heights) and
                                  0 <= nc < len(heights[0]) and
                                  abs(heights[nr][nc]-heights[r][c]) <= x and
                                  not lookup[nr][nc]):
                              continue
                      lookup[nr][nc] = True
                      q.append((nr, nc))
              return False            
          
          left, right = 0, 10**6
          while left <= right:
              mid = left + (right-left)//2
              if check(heights, mid):
                  right = mid-1
              else:
                  left = mid+1
          return left
function_tokens: def minimumEffortPath ( self , heights ) : directions = [ ( 0 , 1 ) , ( 1 , 0 ) , ( 0 , - 1 ) , ( - 1 , 0 ) ] def check ( heights , x ) : lookup = [ [ False ] * len ( heights [ 0 ] ) for _ in xrange ( len ( heights ) ) ] q = collections . deque ( [ ( 0 , 0 ) ] ) while q : r , c = q . popleft ( ) if ( r , c ) == ( len ( heights ) - 1 , len ( heights [ 0 ] ) - 1 ) : return True for dr , dc in directions : nr , nc = r + dr , c + dc if not ( 0 <= nr < len ( heights ) and 0 <= nc < len ( heights [ 0 ] ) and abs ( heights [ nr ] [ nc ] - heights [ r ] [ c ] ) <= x and not lookup [ nr ] [ nc ] ) : continue lookup [ nr ] [ nc ] = True q . append ( ( nr , nc ) ) return False left , right = 0 , 10 ** 6 while left <= right : mid = left + ( right - left ) // 2 if check ( heights , mid ) : right = mid - 1 else : left = mid + 1 return left