We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dea3c32 commit bf99d1aCopy full SHA for bf99d1a
C++/knight-probability-in-chessboard.cpp
@@ -13,10 +13,10 @@ class Solution {
13
for (int j = 0; j < N; ++j) {
14
dp[step % 2][i][j] = 0;
15
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];
+ auto rr = i + direction.first;
+ auto cc = j + direction.second;
+ if (0 <= cc && cc < N && 0 <= rr && rr < N) {
+ dp[step % 2][i][j] += 0.125l * dp[(step - 1) % 2][rr][cc];
20
}
21
22
0 commit comments