DAILY LEETCODE SOLUTION || EASY C++ SOLUTION
\n// Upvote If You Like\nclass Solution {\npublic:\n    vector<int> ans;\n    void dfs(int i,int j,int m,int n,vector<vector<int>> &grid)\n    {\n        if(i==
```\n// Upvote If You Like\nclass Solution {\npublic:\n    vector<int> ans;\n    void dfs(int i,int j,int m,int n,vector<vector<int>> &grid)\n    {\n        if(i==m)\n        {\n            if(j>=0&&j<n)\n            {\n                ans.push_back(j);\n                return ;\n            }\n            else\n            {\n                ans.push_back(-1);\n                return ;\n            }\n        }\n        if((grid[i][j]==1&&j==n-1)||(grid[i][j]==-1&&j==0))\n        {\n            ans.push_back(-1);\n            return ;\n        }\n        if((grid[i][j]==1&&grid[i][j+1]==-1)||(grid[i][j]==-1&&grid[i][j-1]==1))\n        {\n            ans.push_back(-1);\n            return;\n        }\n        if(grid[i][j]==1)\n        {\n            dfs(i+1,j+1,m,n,grid);\n        }\n        else\n        {\n            dfs(i+1,j-1,m,n,grid);\n        }\n    }\n    vector<int> findBall(vector<vector<int>>& grid) {\n        int m=grid.size();\n        int n=grid[0].size();\n        for(int j=0;j<n;j++)\n        {\n            dfs(0,j,m,n,grid);\n        }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'Matrix', 'Simulation']