Beats 99% || Depth-First Search Solution || Graph
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> ball;\n    void dfs(int i, int j, int idx, vector<vector<int>> &grid){\n        if(i == grid.size()){\n            if(j >= 0 && j < grid[0].size()){\n                ball[idx] = j;\n            }\n            return;\n        }\n        if(grid[i][j] == 1){\n            if(j == grid[0].size() - 1 || grid[i][j+1] == -1) return;\n            else{\n                dfs(i+1, j+1, idx, grid);\n            }\n        }\n        else if(grid[i][j] == -1){\n            if(j == 0 || grid[i][j-1] == 1) return;\n            else{\n                dfs(i+1, j-1, idx, grid);\n            }\n        }\n    } \n    vector<int> findBall(vector<vector<int>>& grid) {\n        int n = grid[0].size(); \n        ball = vector<int> (n, -1);\n        for(int i = 0; i<n; i++){\n            dfs(0, i, i, grid);\n        }\n        return ball;\n    }\n};\n```
['Depth-First Search', 'C++']