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.
My simple Java Solution -
Just fill all the positions in the grid with the number of moves it takes to rech there. Populate the whole grid and then index to the (goalX, goalY) to find the answer. I have used Queue to store the next move. Also used a helper grip (of same dimension as nxn) to store 1 if that node has been visited, else one.
Castle on the Grid
You are viewing a single comment's thread. Return to all comments →
My simple Java Solution - Just fill all the positions in the grid with the number of moves it takes to rech there. Populate the whole grid and then index to the (goalX, goalY) to find the answer. I have used Queue to store the next move. Also used a helper grip (of same dimension as nxn) to store 1 if that node has been visited, else one.
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.; import java.lang.;
public class Solution {
}
class Point{
}