Skip to content

Commit 3c87274

Browse files
Time: 27 ms (32.00%), Space: 5.4 MB (76.00%) - LeetHub
1 parent 32c6316 commit 3c87274

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

576-out-of-boundary-paths/576-out-of-boundary-paths.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ func Dynamic(m int, n int, N int, startRow int, startColumn int) int{
2626
}
2727
dirs := [][]int{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}
2828
for s := 1; s <= N; s++ {
29-
for x := 0; x < m; x++ {
30-
for y := 0; y < n; y++ {
29+
for i := 0; i < m; i++ {
30+
for j := 0; j < n; j++ {
3131
for _, dir := range dirs {
32-
tx := dir[0] + x
33-
ty := dir[1] + y
32+
tx := dir[0] + i
33+
ty := dir[1] + j
3434
if ty < 0 || tx < 0 || ty >= n || tx >= m {
35-
dp[s][x][y] += 1
35+
dp[s][i][j] += 1
3636
} else {
37-
dp[s][x][y] = (dp[s][x][y] + dp[s-1][tx][ty]) % mod
37+
dp[s][i][j] = (dp[s][i][j] + dp[s-1][tx][ty]) % mod
3838
}
3939
}
4040
}

0 commit comments

Comments
 (0)