Easy DFS C++ Solution
\nclass Solution {\npublic:\n    vector <int> ans;\n    void dfs(vector<vector<int>>&grid,int i,int j)\n    {\n        int row=grid.size();\n        int col=gri
```\nclass Solution {\npublic:\n    vector <int> ans;\n    void dfs(vector<vector<int>>&grid,int i,int j)\n    {\n        int row=grid.size();\n        int col=grid[0].size();\n        \n        //Condition where ball reaches the end;\n        if(i>=row)\n        {\n           ans.push_back(j);\n           return;\n        }\n        \n        //check for left diagonal movement\n        if(grid[i][j]==1)\n        {\n            if(j==col-1||grid[i][j+1]==-1)\n            {\n                ans.push_back(-1);\n                return;\n            }\n        }\n        \n        //check for right diagonal movement\n        if(grid[i][j]==-1)\n        {\n            if(j==0||grid[i][j-1]==1)\n            {\n                ans.push_back(-1);\n                return;\n            }\n        }\n        \n        //recursive dfs;\n        dfs(grid,i+1,j+grid[i][j]);\n    }\n    \n    vector<int> findBall(vector<vector<int>>& grid) {\n        \n        //running dfs on all elements in the first row\n        for(int i=0;i<grid[0].size();i++)\n        {\n            dfs(grid,0,i);\n        }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'Recursion']