(UVA) Knight Moves - Solução 2
You can see another solution for this problem here . The difference between the solution mentioned above and this new one is that, for this case, I do not use the adjacency list. Then, I have changed the Breadth-First Search method. Now, I only look for the "reachable nodes" when I am in this method. Comparing the run time between the two solutions: - The first one ran in: 0.462s. - The second one ran in: 0.365s. The solution from 2014 ran in 0.612s. import java.io.*; import java.util.*; class Main { public static final int MAX = 8; public static int bfs(int startR, int startC, int goalR, int goalC) { int[] vi = {2,2,-2,-2,1,1,-1,-1}; int[] vj = {1,-1,1,-1,2,-2,2,-2}; Queue<Element> queue = new ArrayDeque<Element...