We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Castle on the Grid
Castle on the Grid
Sort by
recency
|
335 Discussions
|
Please Login in order to post a comment
Shouldn't test case 0 expect return value of 4? It expects 3, but i don't see how could it be done in 3 moves. All other test cases are green in my case.
include
include
include
using namespace std;
struct Node { int x, y, moves; };
int minimumMoves(vector grid, int startX, int startY, int goalX, int goalY) { int n = grid.size(); vector> visited(n, vector(n, false)); queue q; q.push({startX, startY, 0}); visited[startX][startY] = true;
}
int main() { int n; cin >> n; vector grid(n); for (int i = 0; i < n; ++i) cin >> grid[i];
return 0; }
It would be helpful if the description specified whether or not one MUST go until you hit a wall or the edge (think video game ice grid puzzles) or if the player can optionall stop short (think rook in chess). The name of this gives a hint for those familiar with chess, but I do not think it is obvious from the problem description alone to someone unfamiliar with that game.
Solution in C using BFS algorithm