Javascript | Simple Solution w/ Explanation | beats 100% / 82%
Idea:\n\nIn order to move downward, both the cell the ball enters and the one to the side following the slant must have the same slant. If they do, then the bal
***Idea:***\n\nIn order to move downward, both the cell the ball enters and the one to the side following the slant must have the same slant. If they do, then the ball will follow the slant, down and over one.\n\nAs the cell contents conveniently imply a direction, we can simply use the cell values directly with great efficiency.\n\nThe best result for the code below is **72ms / 40.6MB**.\n\n` `\n***Implementation:***\n\nWe need to iterate through all the **start** positions and then track the ball as it drops through the **grid** cells, represented by **grid[i][j]**. Since we\'ll want to use our final value of **j** to update our **ans**, we\'ll need to define it outside the inner **for** loop to broaden its scope.\n\nWe\'ll need to iterate through the rows (**i**) and at each cell, compare the direction (**dir**) of the cell\'s slant to that of the cell on the side following the slant. Conveniently, we can use the value of **dir** programmatically to find which cell to check (**grid[i][j+dir]**).\n\nIf the two cells match, then the ball moves on to the next row, shifted one cell in the **dir** of the slant. If the cells don\'t match (which includes **j** going out of bounds) then the ball will not be able to continue downard, so we should set **j = -1** and jump to the end of this loop with **i = m**.\n\nOnce the ball reaches the end, we store the current **j** value in our **ans**, before ultimately returning the completed **ans**.\n\n` `\n***Code (Readability):***\n```\nvar findBall = function(grid) {\n    let m = grid.length,\n        n = grid[0].length,\n        ans = []\n    for (let start = 0; start < n; start++) {     // Iterate through the different starting conditions\n        let j = start\n        for (let i = 0; i < m; i++) {             // Then iterate downward from grid[i][j]\n            let dir = grid[i][j]                  // Compare the direction of the current cell to the direction\n            if (dir === grid[i][j+dir]) j += dir  //   of the cell on the slant side and move that way if matched\n            else i = m, j = -1                    // Otherwise jump to the loop\'s end and set j to the fail value\n        }\n        ans[start] = j                            // Update the answer\n    }\n    return ans                                    // Return the completed answer\n};\n```\n` `\n***Code (Condensed):***\n```\nvar findBall = function(G) {\n    let m = G.length, n = G[0].length, ans = []\n    for (let s = 0, j = 0; s < n; ans[s] = j, j = ++s)\n        for (let i = 0, d = G[0][j]; i < m; d = G[++i]?.[j])\n            if (d === G[i][j+d]) j += d\n            else i = m, j = -1\n    return ans\n};\n```
['JavaScript']