Swift
swift\n//Where Will the Ball Fall\n//O(n), O(1)\n    func findBall(_ grid: [[Int]]) -> [Int] {\n        var res = [Int]()\n        let rows = grid.endIndex, col
```swift\n//Where Will the Ball Fall\n//O(n), O(1)\n    func findBall(_ grid: [[Int]]) -> [Int] {\n        var res = [Int]()\n        let rows = grid.endIndex, cols = grid[0].endIndex\n        next: for i in 0..<cols {\n            var currRow = 0, currCol = i\n            while currRow < rows {\n                if grid[currRow][currCol] == 1 {\n                    guard currCol + 1 < cols else {\n                        res.append(-1)\n                        continue next\n                    }\n                    if grid[currRow][currCol+1] == 1 {\n                        currRow += 1\n                        currCol += 1\n                    } else {\n                        res.append(-1)\n                        continue next\n                    }\n                } else {\n                    guard currCol-1 >= 0 else {\n                        res.append(-1)\n                        continue next\n                    }\n                    if grid[currRow][currCol-1] == -1 {\n                        currRow += 1\n                        currCol -= 1\n                    } else {\n                        res.append(-1)\n                        continue next\n                    }\n                }\n            }\n            res.append(currCol)\n        }\n        return res\n    }\n```
[]