C++ || DFS || With Explanation || Easy
Start from all the cell connected with pacific ocean and visit all the cell that are greater than or equal to curent cell (since water can flow from adjacent ce
*  Start from all the cell connected with pacific ocean and visit all the cell that are greater than or equal to curent cell **(since water can flow from adjacent cell if height is equal or lower)**\n* **cell connected with pacific** ocean have either **i==0 or j==0**\n* If height is greater or equal means water will be able to reach pacific ocean i.e. this cell is reachable by pacific ocean\n<img src="https://assets.leetcode.com/users/images/8172d3fb-d4c0-42ac-a67c-687c17130bd3_1661938631.9706295.png" alt="drawing" width="500"/>\n* Start from all the cell connected with Atlantic ocean and visit all the cell that are greater than or equal to curent cell **(since water can flow from adjacent cell if height is equal or lower)**\n* **cells connected to atlantic** ocean have either **i==n-1 or j==m-1**\n*  If height is greater or equal means water will be able to reach Atlantic ocean i.e. this cell is reachable by Atlantic ocean\n<img src="https://assets.leetcode.com/users/images/4c38fc61-9561-4a23-96d9-5686d3f91635_1661938716.8930888.png" alt="drawing" width="500">\n* Finally include those cells in ans that are reachable from both pacific and atlantic oceans **(means from these cell water can flow in both oceans)**\n<img src="https://assets.leetcode.com/users/images/2f6384b3-5e43-4935-9b08-a968f1ec9e97_1661939112.8621476.png" alt="drawing" width="500">\n\n```\nclass Solution {\npublic:\n    void dfs(vector<vector<int>>&heights,vector<vector<int>>&oceans,int i,int j,int n,int m)\n    {\n        if(i<0 || i>n-1 || j<0 || j>m-1) return;\n        if(!oceans[i][j])\n        {\n            oceans[i][j]=1;\n            if(i-1>=0 && heights[i-1][j]>=heights[i][j]) dfs(heights,oceans,i-1,j,n,m);\n            if(i+1<n && heights[i+1][j]>=heights[i][j]) dfs(heights,oceans,i+1,j,n,m); \n            if(j-1>=0 && heights[i][j-1]>=heights[i][j]) dfs(heights,oceans,i,j-1,n,m);\n            if(j+1<m && heights[i][j+1]>=heights[i][j]) dfs(heights,oceans,i,j+1,n,m);\n        }\n    }\n    vector<vector<int>> pacificAtlantic(vector<vector<int>>& heights) {\n        int n=heights.size();\n        int m=heights[0].size();\n        vector<vector<int>>pacific(n,vector<int>(m,0));\n        vector<vector<int>>atlantic(n,vector<int>(m,0));\n        vector<vector<int>>ans;\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<m;j++)\n            {\n                if(i==0 || j==0){\n                    if(!pacific[i][j])\n                    {\n                        dfs(heights,pacific,i,j,n,m);\n                    }\n                }\n            }\n        }\n        \n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<m;j++)\n            {\n                if(i==n-1 || j==m-1){\n                    if(!atlantic[i][j])\n                    {\n                        dfs(heights,atlantic,i,j,n,m);\n                    }\n                }\n            }\n        }\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<m;j++)\n            {\n                if(pacific[i][j] && atlantic[i][j])\n                    ans.push_back({i,j});\n            }\n        }\n        return ans;\n    }\n};\n```\n
['Depth-First Search', 'Graph', 'C']