Skip to content

Commit 7862bd4

Browse files
committed
Runtime: 111 ms (Top 27.88%) | Memory: 42.8 MB (Top 44.48%)
1 parent 98e3b96 commit 7862bd4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1+
// Runtime: 111 ms (Top 27.88%) | Memory: 42.8 MB (Top 44.48%)
12
var uniquePathsWithObstacles = function(obstacleGrid) {
23
const m = obstacleGrid.length;
34
const n = obstacleGrid[0].length;
4-
5+
56
const results = new Array(m).fill(0);
67
for (let i = 0; i < m; i++) {
78
results[i] = new Array(n).fill(0);
89
}
9-
10+
1011
for (let i = 0; i < m; i++) {
1112
for (let j = 0; j < n; j++) {
1213
if (i === 0 && j === 0) {
1314
results[0][0] = obstacleGrid[0][0] ? 0 : 1;
1415
} else if (!obstacleGrid[i][j]) {
1516
const up = i === 0 ? 0 : results[i - 1][j];
1617
const left = j === 0 ? 0 : results[i][j - 1];
17-
18+
1819
results[i][j] = up + left;
19-
}
20+
}
2021
}
2122
}
22-
23+
2324
return results[m - 1][n - 1];
24-
}
25+
}

0 commit comments

Comments
 (0)