现在我正在使用递归回溯,我的任务是找到迷宫中最长的路径,质量表示为用坐标覆盖的字段,并且墙壁的坐标在文件中是酸痛的.
我已经制作了一个解析器来解析输入文件并构建墙,但我也将这个坐标存储在一个对象类型Coordinate的数组中,以检查是否有可能在下一个“蛇”上移动下一个“蛇”字段,然后我创建了这个方法,现在我已经明白我需要一个方法来从数组中删除最后一个坐标,当我使用回溯时,我该怎么办?目标不是使用数组列表或链表只有数组!
谢谢!
public class Coordinate {
int xCoord;
int yCoord;
Coordinate(int x,int y) {
this.xCoord=x;
this.yCoord=y;
}
public int getX() {
return this.xCoord;
}
public int getY() {
return this.yCoord;
}
public String toString() {
return this.xCoord + "," + this.yCoord;
}
}
和
public class Row {
static final int MAX_NUMBER_OF_COORD=1000;
Coordinate[] coordArray;
int numberOfElements;
Row(){
coordArray = new Coordin