C++ Simple Code (with video)
\nclass Solution {\npublic:\n    int dp[105][105];\n    int n,m;\n    bool isValid(int x, int y){\n        return (x>=0 && x<n && y>=0 && y<m);\n    }\n    \n  
```\nclass Solution {\npublic:\n    int dp[105][105];\n    int n,m;\n    bool isValid(int x, int y){\n        return (x>=0 && x<n && y>=0 && y<m);\n    }\n    \n    int ok(vector<vector<int>>& grid , int r, int c){\n        if(r==n) return c;\n        if(isValid(r,c)){\n            if(grid[r][c]==1 && isValid(r,c+1) && grid[r][c+1]==1){\n                if(dp[r+1][c+1]!=-2) return dp[r+1][c+1];\n                else{\n                    return dp[r+1][c+1] = ok(grid,r+1,c+1);\n                }\n            } \n            if(grid[r][c]==-1 && isValid(r,c-1) && grid[r][c-1]==-1){\n                if(dp[r+1][c-1]!=-2) return dp[r+1][c-1];\n                else{\n                    return dp[r+1][c-1] = ok(grid,r+1,c-1);\n                }\n            } \n        }\n        return -1;\n    }\n    \n    vector<int> findBall(vector<vector<int>>& grid) {\n        n=grid.size();\n        m=grid[0].size();\n        for(int i=0;i<=101;i++){\n            for(int j=0;j<=101;j++) dp[i][j]=-2;\n        }\n        vector<int>ans(m);\n        for(int i=0;i<m;i++){\n            ans[i]=ok(grid,0,i);\n        }\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C']