C++ || Faster than 98% || Simple Code || ✅⭐⭐
DO UPVOTE IF IT HELPS !!!!!\n\t\n\t#define vvi vector>\n\t#define vvb vector>\n\t#define vb vector\n\n\tclass Solution {\n\tpublic:\n\t\tint n, m;\n\n\t\t// Go 
***DO UPVOTE IF IT HELPS !!!!!***\n\t\n\t#define vvi vector<vector<int>>\n\t#define vvb vector<vector<bool>>\n\t#define vb vector<bool>\n\n\tclass Solution {\n\tpublic:\n\t\tint n, m;\n\n\t\t// Go througout the adjacent if the adjacent\'s height is more or equal to current height\n\t\tvoid dfs(vvi& grid, vvb& flag, int x, int y) {\n\t\t\tflag[x][y] = true;\n\t\t\tif (x - 1 >= 0 && !flag[x - 1][y] && grid[x - 1][y] >= grid[x][y])\n\t\t\t\tdfs(grid, flag, x - 1, y);\n\t\t\tif (x + 1 < n && !flag[x + 1][y] && grid[x + 1][y] >= grid[x][y])\n\t\t\t\tdfs(grid, flag, x + 1, y);\n\t\t\tif (y - 1 >= 0 && !flag[x][y - 1] && grid[x][y - 1] >= grid[x][y])\n\t\t\t\tdfs(grid, flag, x, y - 1);\n\t\t\tif (y + 1 < m && !flag[x][y + 1] && grid[x][y + 1] >= grid[x][y])\n\t\t\t\tdfs(grid, flag, x, y + 1);\n\t\t}\n\n\t\tvvi pacificAtlantic(vvi& heights) {\n\t\t\tn = heights.size();\n\t\t\tm = heights[0].size();\n\n\t\t\tvvb flag1(n, vb(m)), flag2(n, vb(m));\n\t\t\tvvi ans;\n\n\t\t\t// Pacific\n\t\t\t// Do DFS starting from upper border and left border\n\t\t\t// Mark true in flag1 if posibble\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tdfs(heights, flag1, i, 0);\n\t\t\tfor (int i = 1; i < m; i++)\n\t\t\t\tdfs(heights, flag1, 0, i);\n\n\t\t\t// Attlantic\n\t\t\t// DFS starting from bottom border and right border\n\t\t\t// Mark true in flag2 if posibble\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tdfs(heights, flag2, i, m - 1);\n\t\t\tfor (int i = 0; i < m - 1; i++)\n\t\t\t\tdfs(heights, flag2, n - 1, i);\n\n\t\t\t// Add cordinate to ans if both flag1 and flag2 is equal to true\n\t\t\tfor (int i = 0; i < n; i++) for (int j = 0; j < m; j++)\n\t\t\t\tif (flag1[i][j] && flag2[i][j])\n\t\t\t\t\tans.push_back({i, j});\n\n\t\t\treturn ans;\n\t\t}\n\t};
['Depth-First Search', 'Graph', 'C']