猿辅导笔试第一题

 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:50
感觉判题系统有问题
点赞 回复 分享
发布于 2019-08-24 17:36

相关推荐

2025-12-14 11:43
黑龙江大学 Java
用微笑面对困难:确实比较烂,可以这么修改:加上大学的qs排名,然后大学简介要写一些,然后硕士大学加大加粗,科研经历第一句话都写上在复旦大学时,主要负责xxxx,简历左上角把学校logo写上,建议用复旦大学的简历模板
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务