C++ Solution || BFS Implementation || Easy to understand clean code
First of all many of us might be having some issues understanding the problem.\n\nConfusion : Is water going from ocean to island?\n\nNo, actually we are given 
First of all many of us might be having some issues understanding the problem.\n\n**Confusion : Is water going from ocean to island?**\n\nNo, actually we are given an island and we are asked if we supply a specific coordinate with water then tell us the flow of water.\nCan the water flow to both pacific and atlantic ocean from a specific coordinate ? If yes then add that coordinate in your answer.\n\nHope you got the point!\n\n\tvector<vector<int>> pacificAtlantic(vector<vector<int>>& heights) {\n        int n = heights.size();\n        int m = heights[0].size();\n        \n\t\t//the points from where its possible to flow water to pacific\n        vector<vector<bool> > pacific(n, vector<bool> (m,false));\n\t\t//same for atlantic\n        vector<vector<bool> > atlantic(n, vector<bool> (m,false));\n        \n\t\t//utility queues for both oceans\n        queue<pair<int,int> > pq;\n        queue<pair<int,int>> aq;\n        \n\t\t//push the respective boundary elements to the pacific and atlantic queue and bool array\n        for(int i=0; i<n; i++){\n            for(int j=0; j<m; j++){\n                if(i == 0 || j == 0){\n                    pq.push({i,j});\n                    pacific[i][j] = true;\n                }\n                \n                if(i == n-1 || j == m-1){\n                    aq.push({i,j});\n                    atlantic[i][j] = true;\n                }\n            }\n        }\n        \n\t\t//final answer array containing commom points\n        vector<vector<int> > ans;\n        \n        bfs(heights, pq, pacific);\n        bfs(heights, aq, atlantic);\n        \n        for(int i=0; i<n; i++){\n            for(int j=0; j<m; j++){\n                if(pacific[i][j] && atlantic[i][j]){\n                    ans.push_back({i,j});\n                }\n            }\n        }\n        \n        return ans;\n                                       \n    }\n    \n    void bfs(vector<vector<int>> &heights, queue<pair<int,int> > q, vector<vector<bool> > &vis){\n        int n = heights.size();\n        int m = heights[0].size();\n        \n\t\t//direction arrays\n        vector<int> dx = {0,0,1,-1};\n        vector<int> dy = {-1,1,0,0};\n        \n        while(!q.empty()){\n            int x = q.front().first;\n            int y = q.front().second;\n            \n            q.pop();\n            \n\t\t\t//iterate all 4 directions\n            for(int i=0; i<4; i++){\n                int nx = x + dx[i];\n                int ny = y + dy[i];\n                \n\t\t\t\t//along with all the eligibility criteria the next coordinates height must be greater than or equal to the current coordinates heights cause we are moving from ocean to island and\n\t\t\t\t//we want the water to go from island to ocean.\n                if(nx >= 0 && ny >= 0 && nx < n && ny < m && vis[nx][ny] == false && heights[nx][ny] >= heights[x][y]){\n                    q.push({nx,ny});\n                    vis[nx][ny] = true;\n                }\n            }\n        }\n        \n        return ;\n    }\n\t\n**ps: feel free to ask any question in the comment section : )**
['Breadth-First Search', 'C']