#include using namespace std;  vector dir    = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };  struct node {      int height;    int x, y;};  struct Compare {          bool operator()(node const& a, node const& b)    {        return a.height > b.height;    }};  int trapRainWater(vector& heightMap){    int M = heightMap.size();    int N = heightMap[0].size();              vector visited(M,                                  vector(N, false));          priority_queue pq;          for (int i = 0; i […]

Continue Reading