贴一个亚信的笔试题




#亚信安全##笔试题目#
全部评论
写出你们所有的解法呢,复杂度尽量低的!🤔
点赞 回复 分享
发布于 2019-09-10 18:55
给大佬们献丑了,有啥问题及时指出,谢谢~
点赞 回复 分享
发布于 2019-09-19 14:46
用hashmap,如果有互斥的值,将互斥的键的值加1,最后计算键的值大于1的数量 public static int Maxcount(int p,int []array){         if (array==null||array.length==0||p<=1)             return 0;         HashMap<Integer,Integer>map1=new HashMap<>();         for (int i=0;i<array.length;i++){             map1.put(array[i],!map1.containsKey(array[i])?1:map1.get(array[i])+1);         }         int count=0;         for (int i=0;i<array.length;i++) {             if (map1.containsKey(array[i] * p)) {                 map1.put(array[i], map1.get(array[i]) + 1);                 map1.put(array[i] * p, map1.get(array[i] * p) + 1);             }         }         for (int temp:map1.keySet())             if (temp>1)                 count++;         return count;     }
点赞 回复 分享
发布于 2019-09-19 20:24

相关推荐

EEbond:给北邮✌️跪了
点赞 评论 收藏
分享
评论
点赞
6
分享

创作者周榜

更多
牛客网
牛客企业服务