JAVA || Easy Solution With Explanation || 98% Faster Code
\tPLEASE UPVOTE IF YOU LIKE.\n\nclass Solution {\n    public int[] findBall(int[][] grid) {\n        int m = grid.length;\n        int n = grid[0].length;\n\n  
\tPLEASE UPVOTE IF YOU LIKE.\n```\nclass Solution {\n    public int[] findBall(int[][] grid) {\n        int m = grid.length;\n        int n = grid[0].length;\n\n        final int[] result = new int[n];\n        for (int i = 0; i < n; ++i) {\n            int cy = 0;\n            int cx = i;\n            while(cy < m && !isBlocked(grid, cy, cx)) {\n                cx += grid[cy][cx];\n                cy += 1;\n            }\n\n            result[i] = cy == m ? cx : -1;\n        }\n\n        return result;\n    }\n\n    private boolean isBlocked(\n        int[][] grid,\n        int cy,\n        int cx\n    ) {\n        int n = grid[0].length;\n        return (grid[cy][cx] == 1 && cx == n - 1) // will hit right wall\n            || (grid[cy][cx] == -1 && cx == 0)    // will hit left wall\n            || (grid[cy][cx] == 1 && grid[cy][cx + 1] == -1) // V shape with next\n            || (grid[cy][cx] == -1 && grid[cy][cx - 1] == 1); // V shape with previous\n    }\n}\n```
['Java']