Skip to content

Commit bf99d1a

Browse files
authored
Update knight-probability-in-chessboard.cpp
1 parent dea3c32 commit bf99d1a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

C++/knight-probability-in-chessboard.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class Solution {
1313
for (int j = 0; j < N; ++j) {
1414
dp[step % 2][i][j] = 0;
1515
for (const auto& direction : directions) {
16-
auto r = i + direction.first;
17-
auto c = j + direction.second;
18-
if (0 <= c && c < N && 0 <= r && r < N) {
19-
dp[step % 2][i][j] += 0.125 * dp[(step - 1) % 2][r][c];
16+
auto rr = i + direction.first;
17+
auto cc = j + direction.second;
18+
if (0 <= cc && cc < N && 0 <= rr && rr < N) {
19+
dp[step % 2][i][j] += 0.125l * dp[(step - 1) % 2][rr][cc];
2020
}
2121
}
2222
}

0 commit comments

Comments
 (0)