C++ Implementation (DFS)
C++ Implementation of the following amazing post:\nhttps://leetcode.com/problems/pacific-atlantic-water-flow/discuss/90739/Python-DFS-bests-85.-Tips-for-all-DFS
C++ Implementation of the following amazing post:\nhttps://leetcode.com/problems/pacific-atlantic-water-flow/discuss/90739/Python-DFS-bests-85.-Tips-for-all-DFS-in-matrix-question.\n\n```\nclass Solution {\npublic:\n    int dx[4] = {0, 1, -1, 0};\n    int dy[4] = {1, 0, 0, -1};\n    \n    void dfs(vector<vector<int>>& grid, vector<vector<bool>>& v, int i, int j, int height) {\n        if (i < 0 || i > grid.size()-1 || j < 0 || j > grid[0].size()-1 || v[i][j]) return;\n        if (grid[i][j] < height) return;\n        v[i][j] = true;\n        for (int k=0; k<4; k++) {\n            dfs(grid, v, i+dx[k], j+dy[k], grid[i][j]);\n        }\n    }\n    \n    vector<vector<int>> pacificAtlantic(vector<vector<int>>& matrix) {\n        vector<vector<int>> ans;\n        if (!matrix.size()) return ans;\n        vector<vector<bool>> v1(matrix.size(), vector<bool>(matrix[0].size(), false));\n        vector<vector<bool>> v2(matrix.size(), vector<bool>(matrix[0].size(), false));\n        for (int i=0; i<matrix.size(); i++) {\n            dfs(matrix, v1, i, 0, INT_MIN);\n            dfs(matrix, v2, i, matrix[0].size()-1, INT_MIN);\n        }\n        for (int j=0; j<matrix[0].size(); j++) {\n            dfs(matrix, v1, 0, j, INT_MIN);\n            dfs(matrix, v2, matrix.size()-1, j, INT_MIN);\n        }\n        for (int i=0; i<matrix.size(); i++) {\n            for (int j=0; j<matrix[0].size(); j++) {\n                if (v1[i][j] && v2[i][j]) {\n                    vector<int> temp{i, j};\n                    ans.push_back(temp);\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'C', 'C++']