C++ || DFS || O(N*M)
```\nclass Solution {\npublic:\n    int gen(int i, int j, vector>& grid){\n        \n        if(i==grid.size()){\n            return j;\n        }\n        \n  
```\nclass Solution {\npublic:\n    int gen(int i, int j, vector<vector<int>>& grid){\n        \n        if(i==grid.size()){\n            return j;\n        }\n        \n        if(grid[i][j]==1 && j+1<grid[0].size() && grid[i][j+1]==1){\n            return gen(i+1, j+1, grid); // Left ti Right Case\n        }\n        else if(grid[i][j]==-1 && j-1>=0 && grid[i][j-1]==-1){\n            return gen(i+1, j-1, grid); // Right ti Left Case\n        }\n        else if(grid[i][j]==1 && j+1==grid[0].size()){\n            return -1; // Right Wall Case\n        }\n        else{\n            return -1; // Left Wall Case\n        }\n        \n    }\n    \n    vector<int> findBall(vector<vector<int>>& grid) {\n        \n        int row = grid.size();\n        int col = grid[0].size();\n        vector<int> ans(col,-1);\n        \n        for(int i=0; i<col; i++){\n            ans[i] = gen(0, i, grid);\n        }\n        return ans;\n        \n    }\n};
['Depth-First Search', 'Recursion', 'C']