3
int minimumObstacles(vector<vector<int>> &grid) {4
int m = grid.size(), n = grid[0].size();5
vector<int> dir = {0, 1, 0, -1, 0};6
vector<vector<int>> dist(m, vector<int>(n, INT_MAX));7
vector<vector<bool>> vis(m, vector<bool>(n, 0));8
deque<pair<int, int>> q;16
for (int i = 0; i < 4; i++) {18
int cy = y + dir[i + 1];19
if (cx >= 0 and cy >= 0 and cx < m and cy < n) {21
dist[cx][cy] = dist[x][y] + (grid[cx][cy] == 1);22
if (grid[cx][cy] == 1)23
q.push_back({cx, cy}); // obstacle cell pushed at the end25
q.push_front({cx, cy}); // empty cell pushed on top31
return dist[m - 1][n - 1];