Python recursive answer with complexity
Time: O(MN)\n- Space: O(M)\n\npython\nclass Solution:\n    def findBall(self, grid: List[List[int]]) -> List[int]:\n        m, n = len(grid), len(grid[0])\n    
- Time: O(MN)\n- Space: O(M)\n\n```python\nclass Solution:\n    def findBall(self, grid: List[List[int]]) -> List[int]:\n        m, n = len(grid), len(grid[0])\n        def col_get_out(row, col):\n            # get out\n            if row == m:\n                return col\n            # if grid[row][col] == -1, then go left\n            # if grid[row][col] == 1, then go right\n            new_col = col + grid[row][col]\n            # stuck\n            if (\n                new_col == -1 # stuck at left\n                or new_col == n # stuck at right\n                or grid[row][new_col] != grid[row][col] # stcuk at \\/\n            ):\n                return -1\n            return col_get_out(row + 1, new_col) # go down\n        answer = []\n        for c in range(n):\n            answer.append(col_get_out(0, c))\n        return answer\n```
['Recursion', 'Python']