Standard BFS in python3, not quite a hard one
Code\n\nclass Solution:\n    def minimumMoves(self, grid: List[List[int]]) -> int:\n        n = len(grid)\n        queue = [(0,1,0,0)]\n        seen = set([(0,1
# Code\n```\nclass Solution:\n    def minimumMoves(self, grid: List[List[int]]) -> int:\n        n = len(grid)\n        queue = [(0,1,0,0)]\n        seen = set([(0,1,0)])\n        for i,j,direc,step in queue:\n            if (i,j,direc) == (n-1,n-1,0):\n                return step\n            if direc == 0:\n                if j < n - 1 and grid[i][j+1] != 1 and (i,j+1,0) not in seen:\n                    seen.add((i,j+1,0))\n                    queue.append((i,j+1,0,step+1))\n                if i < n - 1 and grid[i+1][j] != 1 and grid[i+1][j-1] != 1 and (i+1,j-1,1) not in seen:\n                    seen.add((i+1,j-1,1))\n                    queue.append((i+1,j-1,1,step+1))\n                if i < n - 1 and grid[i+1][j-1]!=1 and grid[i+1][j] != 1 and (i+1,j,0) not in seen:\n                    seen.add((i+1,j,0))\n                    queue.append((i+1,j,0,step+1))\n            else:\n                if i < n - 1 and grid[i+1][j] != 1 and (i+1,j,1) not in seen:\n                    seen.add((i+1,j,1))\n                    queue.append((i+1,j,1,step+1))\n                if j < n - 1 and grid[i][j+1] != 1 and grid[i-1][j+1] != 1 and (i-1,j+1,0) not in seen:\n                    seen.add((i-1,j+1,0))\n                    queue.append((i-1,j+1,0,step+1))\n                if j < n - 1 and grid[i][j+1]!=1 and grid[i-1][j+1] != 1 and (i,j+1,1) not in seen:\n                    seen.add((i,j+1,1))\n                    queue.append((i,j+1,1,step+1))\n        return -1\n                \n\n\n\n        \n```
['Python3']