顺丰科技笔试第二题 只有%20 有大佬ac了吗?分享一下
public class Main {
public static void main(String[] args){Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] array = new int[m];
LinkedList<Integer> list =new LinkedList<Integer>();
if(n>0 && m<=n){
for(Integer i=1;i<=n;i++){
list.add(i);
}
for(int i=0;i<m;i++){
array[i] = sc.nextInt();
for(int j=0;j<list.size();j++){
if(list.get(j)==array[i]){
list.remove((Integer)array[i]);
}
}
}
int len = list.size();
int mid = len/2;
if(len%2!=0){
System.out.println(list.get(mid));
}else{
System.out.println(list.get(mid-1));
}
}
}
}
#安卓工程师##顺丰科技#