该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
把LZ没写好的那部分写了,其他你自己改改,看楼下有没更好的方法,我这个不用排列的:
public static void main(String[] args) {
int[] a = {56,3,6,88,1,2};
int[] b = {3,88,1,2,56,6};
System.out.println(m(a,b));
}
public static boolean m(int[] a,int[] b) {
int[] news = a;
int num = 0,n = a.length;
for(int i = 0; i < b.length; i++) {
go_to:
for(int j = 0; j < n; j++) {
if(b[i] == news[j]) {
news[j] = news[n - 1];
num++;
n--;
break go_to;
}
}
if(num != i + 1) {
return false;
}
}
if(num == a.length) {
return true;
}
else return false;
}