SIMPLE || JAVA SOLUTION || MATRIX || 5ms
\nIF YOU LIKE THE SOLUTION SO PLEASE UPVOTE IT\n\n\nclass Solution {\n    public int[] findBall(int[][] grid) {\n        \n        int row=grid.length;\n       
```\nIF YOU LIKE THE SOLUTION SO PLEASE UPVOTE IT\n```\n```\nclass Solution {\n    public int[] findBall(int[][] grid) {\n        \n        int row=grid.length;\n        int col=grid[0].length;\n        \n        int ans[]=new int[col];\n        \n        for(int i=0;i<col;i++){\n            \n            int j=0,k=i;\n            boolean check=false;\n            \n            while(j<row && k<col){\n                if(grid[j][k]==1){\n                    if((k<col-1 && grid[j][k+1]==-1)  || (k==col-1 && grid[j][k]==1)){\n                        check=true;\n                        break;\n                    }\n                    k++;\n                    j++;\n                }\n                else if(grid[j][k]==-1){\n                    if((k>0 && grid[j][k-1]==1) || (k==0 && grid[j][k]==-1)){\n                        check=true;\n                        break;\n                    }\n                    j++;\n                    k--;\n                }\n            }\n            if(j==row && check==false){\n                ans[i]=k;\n            }\n            else{\n                ans[i]=-1;\n            }\n        }\n        return ans;\n        \n    }\n}\n```
['Java']