Simple Python Iterative Solution Faster than 99%
This solution is much simpler than other solutions because:\n It looks at each ball separately\n It is iterative, and not recursive (and hence allowing us to be
This solution is much simpler than other solutions because:\n* It looks at each ball separately\n* It is iterative, and not recursive (and hence allowing us to be more efficient than 99% of solutions)\n\nFor each ball, we start from the top of the grid and look at the direction where the ball is going to go.\n\nIf the ball hits the sides of the grid (i.e. ```col + direction < 0``` or ```col + direction >= width```) or it gets stuck (i.e. ```grid[row][col] + grid[row][col + direction] == 0```), then we return -1.\n\nOtherwise, we allow the ball to continue down the grid till it reaches the bottom, where we return the col.\n\n```\nclass Solution:\n    def findBall(self, grid: List[List[int]]) -> List[int]:\n\t\theight = len(grid)\n\t\twidth = len(grid[0])\n\t\n\t\tdef _getFallColumn(self, grid: List[List[int]], col: int) -> int:\n\t\t\trow = 0\n\n\t\t\twhile row < height:\n\t\t\t\tdirection = grid[row][col]\n\t\t\t\tif col + direction < 0 or col + direction >= width or grid[row][col] + grid[row][col + direction] == 0:\n\t\t\t\t\treturn -1\n\n\t\t\t\trow += 1\n\t\t\t\tcol += direction\n\n\t\t\treturn col          \n\t\n        return [_getFallColumn(grid, col) for col in range(width)]\n\t\t```
['Depth-First Search', 'Iterator', 'Python']