How come same Python solution got TLE again? Again? Are you kidding me?
Just translated https://leetcode.com/problems/cut-off-trees-for-golf-event/discuss/107404/Java-solution-PriorityQueue-+-BFS into Python. Same time complexity I 
Just translated https://leetcode.com/problems/cut-off-trees-for-golf-event/discuss/107404/Java-solution-PriorityQueue-+-BFS into Python. Same time complexity I believe. How come I got TLE again? If you admins really hate python, you should ban python from available languages. \n\nremember, I pay 100+ dollars per year not for getting TLE for working out the optimal solution that will pass the actual interview.\n\n\'\'\'\n\t\n\tfrom collections import deque\n\n\tclass Solution(object):\n\t    def cutOffTree(self, forest):\n\n\t        if not forest or not forest[0]:\n\t            return -1\n\t        \n\t        # cut the tree in reverse order of tree\'s height\n\t        treeList = []\n\t        for i in xrange(len(forest)):\n\t            for j in xrange(len(forest[0])):\n\t                if forest[i][j] > 1:\n\t                    treeList.append([forest[i][j], [i, j]])\n\t        treeList.sort()\n\t        \n\t        totalSteps = self.minStep(forest, [0, 0], treeList[0][1])\n\t        k = 0\n\t        while k < len(treeList) - 1:\n\t            step = self.minStep(forest, treeList[k][1], treeList[k + 1][1])\n\t            if step == -1:\n\t                return -1\n\t            totalSteps += step\n\t            k += 1\n\t        \n\t        return totalSteps\n\t    \n\t    # do BFS to see if we can find a path from start to end\n\t    def minStep(self, forest, start, end):\n\t        directions = [(0, -1), (0, 1), (-1, 0), (1, 0)]\n\t        step = 0\n\t        m, n = len(forest), len(forest[0])\n\t        visited = [[False for x in xrange(n)] for _ in xrange(m)]\n\t        visited[start[0]][start[1]] = True\n\t        queue = deque()\n\t        queue.append(start)\n\t        \n\t        while queue:\n\t            size = len(queue)\n\t            for i in xrange(size):\n\t                curr = queue.popleft()\n\t                if curr == end:\n\t                    return step\n\t                for direction in directions:\n\t                    nextRow = curr[0] + direction[0]\n\t                    nextCol = curr[1] + direction[1]\n\t                    if nextRow < 0 or nextRow >= m or nextCol < 0 or nextCol >= n or visited[nextRow][nextCol] or forest[nextRow][nextCol] == 0:\n\t                        continue\n\t                    queue.append([nextRow, nextCol])\n\t                    visited[nextRow][nextCol] = True\n\t            step += 1\n\t            \n\t        # here, it means we can never find the destination\n\t        return -1\n\'\'\'
[]