C++ || DFS || Easy Approach
Here is my c++ code for this problem.\n\'\'\'\n\n\tclass Solution {\n\tpublic:\n\t\tvoid dfs(int x, int y, int num, vector>& v, vector>& heights){\n\t\t\tif(x<0
Here is my c++ code for this problem.\n\'\'\'\n\n\tclass Solution {\n\tpublic:\n\t\tvoid dfs(int x, int y, int num, vector<vector<int>>& v, vector<vector<int>>& heights){\n\t\t\tif(x<0 || x>=heights.size() || y<0 || y>=heights[0].size() || heights[x][y]<num || v[x][y]){return;}\n\t\t\tv[x][y]=1;\n\t\t\tdfs(x-1, y, heights[x][y], v, heights);\n\t\t\tdfs(x, y-1, heights[x][y], v, heights);\n\t\t\tdfs(x+1, y, heights[x][y], v, heights);\n\t\t\tdfs(x, y+1, heights[x][y], v, heights);\n\t\t}\n\t\tvector<vector<int>> pacificAtlantic(vector<vector<int>>& heights) {\n\t\t\tvector<vector<int>>v1(heights.size(), vector<int>(heights[0].size(), 0));\n\t\t\tvector<vector<int>>v2(heights.size(), vector<int>(heights[0].size(), 0));\n\t\t\tfor(int i=0; i<heights.size(); i++){\n\t\t\t\tif(!v1[i][0]){dfs(i, 0, heights[i][0], v1, heights);}\n\t\t\t\tif(!v2[i][heights[0].size()-1]){dfs(i, heights[0].size()-1, heights[i][heights[0].size()-1], v2, heights);}\n\t\t\t}\n\t\t\tfor(int i=0; i<heights[0].size(); i++){\n\t\t\t\tif(!v1[0][i]){dfs(0, i, heights[0][i], v1, heights);}\n\t\t\t\tif(!v2[heights.size()-1][i]){dfs(heights.size()-1, i, heights[heights.size()-1][i], v2, heights);}\n\t\t\t}\n\t\t\t// for(int i=0; i<heights.size(); i++){\n\t\t\t//     for(int j=0; j<heights[0].size(); j++){\n\t\t\t//         cout<<v1[i][j]<<" ";\n\t\t\t//     }cout<<endl;\n\t\t\t// }cout<<endl;\n\t\t\t// for(int i=0; i<heights.size(); i++){\n\t\t\t//     for(int j=0; j<heights[0].size(); j++){\n\t\t\t//         cout<<v2[i][j]<<" ";\n\t\t\t//     }cout<<endl;\n\t\t\t// }\n\t\t\tvector<vector<int>>ans;\n\t\t\tfor(int i=0; i<heights.size(); i++){\n\t\t\t\tfor(int j=0; j<heights[0].size(); j++){\n\t\t\t\t\tif(v1[i][j] && v2[i][j]){\n\t\t\t\t\t\tans.push_back({i, j});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ans;\n\t\t}\n\t};\n\'\'\'
['Depth-First Search', 'Graph', 'C']