2
* @param {number[][]} grid5
var minimumObstacles = function (grid) {13
for (let i = 0; i < grid.length; i++) {15
for (let j = 0; j < grid[i].length; j++) {16
distance[i][j] = Number.MAX_SAFE_INTEGER;21
function bfs(row, col) {23
distance[row][col] = 0;24
queue.push([row, col]);25
while (queue.length > 0) {26
let element = queue.shift();29
let originalDist = distance[row][col];30
for (let d = 0; d < dx.length; d++) {31
let i = row + dx[d][0];32
let j = col + dx[d][1];35
i <= grid.length - 1 &&37
j <= grid[i].length - 139
let dist = originalDist;40
if (grid[i][j] === 1) {43
if (distance[i][j] > dist) {44
//Update distance for this neighbour node if the new distance is smaller than the previous distance46
distance[i][j] = dist;51
//return the minimum distance for last cell after completing the process52
return distance[grid.length - 1][grid[row].length - 1];