concise C++ priority_queue solution
\nclass Solution {\npublic:\n    int trapRainWater(vector<vector<int>>& heightMap) {\n        if(heightMap.size()==0) return 0;\n        priority_queue<pair<int
```\nclass Solution {\npublic:\n    int trapRainWater(vector<vector<int>>& heightMap) {\n        if(heightMap.size()==0) return 0;\n        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;\n        int row = heightMap.size(), col = heightMap[0].size();\n        vector<vector<int>> visited(row, vector<int>(col, 0));\n        int ans = 0, Max = INT_MIN;\n        for(int i = 0; i < row; i++)\n        {\n            for(int j = 0; j < col; j++)\n            {\n                if(!(i==0 || i==row-1 || j==0 || j==col-1)) continue;\n                que.push(make_pair(heightMap[i][j], i*col+j));\n                visited[i][j] = 1;\n            }\n        }\n        vector<vector<int>> dir{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};\n        while(!que.empty())\n        {\n            auto val = que.top(); que.pop();\n            int height = val.first, x = val.second/col, y = val.second%col;\n            Max = max(Max, height);\n            for(auto d: dir)\n            {\n                int x2 = x + d[0], y2 = y + d[1];\n                if(x2>=row || x2<0 || y2<0 || y2>=col || visited[x2][y2]) continue;\n                visited[x2][y2] = 1;\n                if(heightMap[x2][y2] < Max) ans += Max - heightMap[x2][y2];\n                que.push(make_pair(heightMap[x2][y2], x2*col+y2));\n            }\n        }\n        return ans;\n    }\n};\n```
[]