[C++] Solution || BFS
Language Used: C++\n\nIf you have any questions, feel free to ask. If you like the solution and explanation, please upvote!\n\nTime Complexity: O(nm);\nSpace Co
**Language Used: C++**\n\n*If you have any questions, feel free to ask. If you like the solution and explanation, please **upvote!***\n\nTime Complexity: O(nm);\nSpace Complexity: O(nm);\n\nIntution:\n*  When we are at lower level, the water must come in it from a higher level. \n*  So for pacific store all the element in the queue which are adjacent to the sea and traverse DFS/BFS to find the higher level.\n*  Do the same for atlantic\n*  Now the level which is covered by both is our answer.\n```\nclass Solution {\npublic:\n    typedef pair<int, int> pii; \n    vector<vector<int>> pacificAtlantic(vector<vector<int>>& h) {\n        // Storing the solution\n        vector<vector<int>> ans;\n        int n = h.size();\n        int m = h[0].size();\n        // Initializing the Pacific and Atlantic matrices;\n        vector<vector<int>> pa(n, vector<int>(m, 0));\n        vector<vector<int>> at(n, vector<int>(m, 0));\n        \n        // BFS for the pacific;\n        queue<pii> q;\n        for(int i{}; i<n; i++) q.push({i, 0});\n        for(int j{}; j<m; j++) q.push({0, j});\n        bfs(h, q, pa);\n        \n        // BFS for the atlantic;\n        queue<pii> q2;\n        for(int i{}; i<n; i++) q2.push({i, m-1});\n        for(int j{}; j<m; j++) q2.push({n-1, j});\n        bfs(h, q2, at);\n        \n        for(int i{}; i<n; i++){\n            for(int j{}; j<m; j++){\n                if(pa[i][j]==1 && at[i][j]==1) ans.push_back({i, j});\n            }\n        }\n        return ans;\n    }\nprivate:\n    void bfs(vector<vector<int>>& h, queue<pii>&q, vector<vector<int>>& vis){\n        int n = h.size(); int m = h[0].size();          // Dimension of the matrix\n        int dx[4] = {-1,0,1,0};\n        int dy[4] = {0,1,0,-1};\n        while(!q.empty()){\n            int x = q.front().first; int y = q.front().second;\n            q.pop(); vis[x][y] = 1;        // Popping the element out ans marking as visited;\n            for(int i{}; i<4; i++){\n                int cx = x + dx[i]; int cy = y + dy[i];\n\t\t\t\t// Checking feasibility of Current_x & Current_y\n                if(cx>=0 && cy>=0 && cx<n && cy<m){\n                    if(h[cx][cy] >= h[x][y] && vis[cx][cy] == 0) q.push({cx, cy});\n                }\n            }\n        }\n    }\n};\n```\nKeep Coding\n**`while(!success){ tryAgain(); } :)`**
['Breadth-First Search', 'C', 'C++']