✅Trapping Rain Water II  C++
Thanks for Visiting\nSyntax of  priority_queue min heap\npriority_queue <int, vector<int>, greater<int>>pq;\n\n\n\nint trapRainWater(vector<vector<int>>& v)\n  
Thanks for Visiting\nSyntax of  priority_queue min heap\n`priority_queue <int, vector<int>, greater<int>>pq;`\n\n\n```\nint trapRainWater(vector<vector<int>>& v)\n    {\n        int n=v.size();\n        int m=v[0].size();\n        priority_queue<pair<int,pair<int,int>> ,vector<pair<int,pair<int,int>>> ,greater<pair<int,pair<int,int>>> >pq;\n        vector<vector<int>>vis(n,vector<int>(m,0));   //visited array\n        for(int i=0;i<n;i++)                          //put all boundary element in priority queue \n        {\n            for(int j=0;j<m;j++)\n            {\n                if(i==0||j==0||i==n-1||j==m-1)\n                {\n                    pq.push({v[i][j],{i,j}});\n                    vis[i][j]=1;                    //mark visited\n                }\n            }\n        }\n        vector<pair<int,int>>dir={{1,0},{0,1},{-1,0},{0,-1}};           //Direction vector\n        int sum=0;\n        while(!pq.empty())                  //BFS\n        {\n            auto it=pq.top();\n            pq.pop();\n            int height=it.first;            //height of current Element\n            int x=it.second.first;          //v[x][y]   \n            int y=it.second.second;\n            for(int i=0;i<4;i++)\n            {\n                int new_x=x+dir[i].first;           \n                int new_y=y+dir[i].second;\n                if(new_x<0||new_y<0||new_x==n||new_y==m||vis[new_x][new_y]==1)      //check condition of out of Boundary and whether that\n                {                                                                  // neighbour is already visited or not\n                    continue;\n                }\n                if(v[new_x][new_y]<height)                                      //if height of current element is more than the neighbour \n                {                                                               //then we can put water in it\n                    sum+=height-v[new_x][new_y];\n                    pq.push({height,{new_x,new_y}});                            //due to water the height of neighbour element will became \n                }                                                               //equal to height of current element\n                else\n                {\n                    pq.push({v[new_x][new_y],{new_x,new_y}});                   //if neighbour height is more that or equal to the height \n                }                                                               //current element then height of neighbour element not change           \n                \n                vis[new_x][new_y]=1;                                            //mark neighbour element if visited\n            }\n        }\n        return sum;\n    }\n```
['Breadth-First Search', 'Heap (Priority Queue)']