C++ || DFS using 2d vector of pair || 90% faster code || Beginner friendly code
\nclass Solution {\npublic:\n    int dx[4]={0,0,1,-1};\n    int dy[4]={1,-1,0,0};\n    void paci(vector<vector<int>>& h,vector<vector<pair<bool,bool>>>& ocean,i
```\nclass Solution {\npublic:\n    int dx[4]={0,0,1,-1};\n    int dy[4]={1,-1,0,0};\n    void paci(vector<vector<int>>& h,vector<vector<pair<bool,bool>>>& ocean,int n,int m,int i,int j){\n        ocean[i][j].first=true;\n        for(int k=0;k<4;k++){\n            int nx=i+dx[k];int ny=j+dy[k];\n            if(nx>=0 && nx<n && ny>=0 && ny<m && !ocean[nx][ny].first && h[nx][ny]>=h[i][j]){\n                paci(h,ocean,n,m,nx,ny);\n            }\n        }\n    }\n    void atla(vector<vector<int>>& h,vector<vector<pair<bool,bool>>>& ocean,int n,int m,int i,int j){\n        ocean[i][j].second=true;\n        for(int k=0;k<4;k++){\n            int nx=i+dx[k];int ny=j+dy[k];\n            if(nx>=0 && nx<n && ny>=0 && ny<m && !ocean[nx][ny].second && h[nx][ny]>=h[i][j]){\n                atla(h,ocean,n,m,nx,ny);\n            }\n        }\n    }\n    vector<vector<int>> pacificAtlantic(vector<vector<int>>& h) {\n        int n=h.size();int m=h[0].size();\n        //ocean.first for pacific \n        //ocean.second for atlantic\n        vector<vector<pair<bool,bool>>> ocean(n,vector<pair<bool,bool>>(m,{false,false}));\n        for(int i=0;i<n;i++){\n            paci(h,ocean,n,m,i,0);\n            atla(h,ocean,n,m,i,m-1);\n        }\n        for(int i=0;i<m;i++){\n            paci(h,ocean,n,m,0,i);\n            atla(h,ocean,n,m,n-1,i);\n        }\n        vector<vector<int>> ans;\n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){\n                if(ocean[i][j].first && ocean[i][j].second)\n                    ans.push_back({i,j});\n            }\n        }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'Graph', 'C++']