public static void main(String[] args){
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String[] list=in.nextLine().split(" ");
int total=Integer.valueOf(list[0]);
int frequence=Integer.valueOf(list[1]);
String[] numtem=in.nextLine().split(" ");
int[] num=new int[numtem.length];
for(int i=0;i<numtem.length;i++){
num[i]=Integer.valueOf(numtem[i]);
}
outputList(num,frequence);
}
}
public static void outputList(int[] num,int frequence){
HashMap<Integer,Integer> list=new HashMap();
List<Integer> index=new LinkedList<>();
for(int i=0;i<num.length;i++){
index.add(num[i]);
list.put(num[i],list.getOrDefault(num[i],0)+1);
}
List<Integer> result=new LinkedList<>();
for(Integer i:index){
if(list.get(i)>frequence){
continue;
}else{
result.add(i);
}
}
int co=0;
for(Integer i:result){
if(co==result.size()-1){
System.out.print(i);
}
System.out.print(i+" ");
co++;
}
}
猿辅导笔试第一题,有哪位老哥能够帮我解答一下为什么显示数组越界,通过率0%;
#猿辅导##笔试题目##题解#