✅C++|| Recursion (DFS)  || Easy Solution
\nclass Solution {\npublic:\n    int dfs(int i,int j, vector<vector<int>>& grid){\n        if(i >= grid.size())\n        {\n            return j;\n        }\n  
```\nclass Solution {\npublic:\n    int dfs(int i,int j, vector<vector<int>>& grid){\n        if(i >= grid.size())\n        {\n            return j;\n        }\n        //left to right\n        if(grid[i][j] == 1 && j+1<grid[0].size() && grid[i][j+1] == 1){\n            return dfs(i+1,j+1,grid);\n        }\n        //right to left\n        else if(grid[i][j] == -1 && j-1>=0 && grid[i][j-1] == -1){\n            return dfs(i+1,j-1,grid);\n        }\n        else if(grid[i][j] == 1 && j+1 >= grid[0].size())\n        {\n            return -1;\n        }\n        else\n        {\n            return -1;\n        }\n        \n    }\n    vector<int> findBall(vector<vector<int>>& grid) {\n        int row = grid.size();\n        int col = grid[0].size();\n        vector<int> ans(col);\n        for(int j=0;j<col;j++){\n            ans[j] = dfs(0,j,grid);\n        }\n        return ans;\n    }\n};\n```\n**Please upvote if it was helpful for you, thank you!**
['C']