Diagonal Traversal | C++ | DFS kind approach
We iterate over each ball, and drop it from the ith cell on top. Now, we simulate the game, and try to find the next cell basis on the direction of the current 
We iterate over each ball, and drop it from the `ith ` cell on top. Now, we simulate the game, and try to find the next cell basis on the direction of the current cell direction.\n\nBall moves to the next diagonal cell -\n1. If direction = 1, that means the cell next to it should be available for move otherwise ball will be blocked.\n2. if direction = -1, then previous cell should be available for movement else, ball is blocked.\n3. if during traversal we encounter the case where the direction of current and next/previous cell is of opposite direction, then ball is stuck in V shape. \n\n\n```\nclass Solution {\npublic:\n    vector<int> findBall(vector<vector<int>>& grid) {\n        int n = grid.size();\n        int m = (int)grid[0].size();\n        \n        auto getValue = [&](const auto &curCell) {\n            return grid[curCell.first][curCell.second];\n        };\n        \n        auto isValidCell = [&] (const auto &curCell) {\n            int u = curCell.first;\n            int v = curCell.second;\n            return (u >= 0 && v >= 0 && u < n && v < m);\n        };\n        \n        auto isBallBlocked = [&] (const auto &cell, const int &dir) {\n            bool isBlocked = false;\n            pair<int, int> nextCell = {cell.first, dir == 1? cell.second + 1: cell.second - 1};\n            if (!isValidCell(nextCell) || getValue(nextCell) == -dir) {\n                    isBlocked = true;\n            }\n            return isBlocked;\n        };\n        \n        vector<int> result(m, -1);\n        //dropping ball from each of the column in the table\n        for (int i = 0; i < m; ++i) {\n            pair<int, int> curCell = {0, i};\n            int curDir = getValue(curCell);\n            \n            while (isValidCell(curCell) && !isBallBlocked(curCell, curDir)) {\n                curCell = {curCell.first + 1, curDir == 1? curCell.second + 1: curCell.second - 1};\n                curDir = isValidCell(curCell) ? getValue(curCell): 1;\n            }\n            \n            if (curCell.first == n) {\n                result[i] = curCell.second;\n            }\n        }\n        return result;\n        \n    }\n};\n```\n
[]