Java Clean DFS
\npublic int[] findBall(int[][] grid) {\n        int[] results = new int[grid[0].length];\n        for (int i = 0; i < grid[0].length; i++) {\n            resul
```\npublic int[] findBall(int[][] grid) {\n        int[] results = new int[grid[0].length];\n        for (int i = 0; i < grid[0].length; i++) {\n            results[i] = dfs(grid, 0, i);\n        }\n\n        return results;\n    }\n\n    private int dfs(int[][] grid, int row, int column) {\n        if (row == grid.length)\n            return column;\n\n        if ((grid[row][column] == 1 && (column == grid[0].length - 1 || grid[row][column + 1] == -1)) ||\n                grid[row][column] == -1 && (column == 0 || grid[row][column - 1] == 1))\n            return -1;\n\n        if (grid[row][column] == 1)\n            return dfs(grid, row + 1, column + 1);\n        else\n            return dfs(grid, row + 1, column - 1);\n    }\n```
['Depth-First Search', 'Java']