Skip to content

Commit 483adf5

Browse files
authored
Update minimum-knight-moves.cpp
1 parent a71f7b8 commit 483adf5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

C++/minimum-knight-moves.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class Solution {
3636
if (x < y) {
3737
swap(x, y);
3838
}
39-
unordered_map<pair<int, int>, int, PairHash<int>> lookup =
39+
static const unordered_map<pair<int, int>, int, PairHash<int>> lookup =
4040
{{{0, 0}, 0}, {{1, 0}, 3}, {{2, 2}, 4}}; // special cases
4141
if (lookup.count({x, y})) {
42-
return lookup[{x, y}];
42+
return lookup.at({x, y});
4343
}
4444
const auto& delta = x - y;
4545
if (y > delta) { // if 2y > x, every period 3 of y with same delta is increased by 2

0 commit comments

Comments
 (0)