C++ || Easy Solution with Explanation in comments using DP ||
\n# Code\n\nclass Solution {\n\nint m , n ;\n\n   int SolveByMemo(vector<vector<int>>& grid , int row , int col ,vector<vector<int>> &dp)\n   {\n       // Base 
\n# Code\n```\nclass Solution {\n\nint m , n ;\n\n   int SolveByMemo(vector<vector<int>>& grid , int row , int col ,vector<vector<int>> &dp)\n   {\n       // Base Case : If We have came out of grid we return its column\n          if(row == m)\n           return col;\n\n        // IF We Have already visited for particular cell  we returned its stored ans\n           if(dp[row][col] != -4)\n           return dp[row][col];\n        \n        // If we are at leftmost column\n           if(col == 0)\n           {\n               // IF cell redirects to left from leftmost cell we the ball gets stuck\n               if(grid[row][col] == -1)\n               return dp[row][col] = -1;\n                \n              // If Cell redirects to right from leftmost we check for the next cell\n               else\n               {\n                // if next cell redirects back to current cell the ball gets stuck\n                  if(grid[row][col+1] == -1 )\n                  return dp[row][col] = -1;\n            // else we can go to next right column of next row\n                  return dp[row][col] = SolveByMemo(grid , row+1 , col+1 , dp);\n               }\n\n           }\n\n        // If we are at rightmost column\n           if(col == n-1)\n           {\n // IF cell redirects to right from rightmost cell we the ball gets stuck\n               if(grid[row][col] == 1)\n               return dp[row][col] = -1;\n             // If Cell redirects to right from leftmost we check for the next cell\n               \n               else\n               {\n            // if prev cell redirects back to current cell the ball gets stuck\n                  if(grid[row][col-1] == 1 )\n                  return dp[row][col] = -1;\n            // else we can go to next left column of next row\n                  return dp[row][col] = SolveByMemo(grid , row+1 , col-1 , dp);\n               }\n           }\n\n           // iF Current cell redirects to right \n           if(grid[row][col] == 1)\n           {\n            // if right cell redirects to left , the ball is stuck \n             if(grid[row][col+1] == -1)\n             return dp[row][col] = -1;\n              // else we can go to next right column of next row\n             return dp[row][col] = SolveByMemo(grid , row+1 , col+1 , dp);\n           }\n           // iF Current cell redirects to left\n           else\n           {\n            // if left cell redirects to right , the ball is stuck \n             if(grid[row][col-1] == 1)\n             return dp[row][col] = -1;\n\n            // else we can go to next left column of next row\n             return dp[row][col] = SolveByMemo(grid , row+1 , col-1 , dp);\n           }\n           return -1;\n   }\n\npublic:\n    vector<int> findBall(vector<vector<int>>& grid) {\n         \n\n        m = grid.size();\n        n = grid[0].size();\n\n\n        //if there is only one  column irrespective of no. of  rows the ball will stuck \n         if(n == 1)\n         return {-1};\n\n\n        vector<int> ans(n , -1);\n\n        vector<vector<int>> dp(m , vector<int> (n , -4) ); \n      \n      for(int i = 0 ; i< n; i++)\n      {\n          // We check for each ball one by one each \n        ans[i] =  SolveByMemo(grid , 0 , i, dp);\n      } \n\n      return ans;\n    }\n};\n```
['Dynamic Programming', 'C++']