猿辅导笔试第一题

 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%;#猿辅导##笔试题目##题解#
全部评论
感觉判题系统有问题
点赞
送花
回复
分享
发布于 2019-08-24 17:36
我的网页也过不去。头大。
点赞
送花
回复
分享
发布于 2019-08-24 17:50
秋招专场
校招火热招聘中
官网直投

相关推荐

投递字节跳动等公司10个岗位
点赞 评论 收藏
转发
点赞 1 评论
分享
牛客网
牛客企业服务