题解 | #记票统计#

记票统计

http://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894

import java.util.*;
public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            while (sc.hasNextLine()) {
                int n = Integer.parseInt(sc.nextLine());
                String[] arr = sc.nextLine().split(" ");
                Map<String,Integer> map = new LinkedHashMap<>();
                for (int i =0; i< arr.length;i++) {
                    map.put(arr[i], 0);
                }
                int k = Integer.parseInt(sc.nextLine());
                 String[] can = sc.nextLine().split(" ");
                for (int i =0; i< can.length; i++) {
                    if (map.containsKey(can[i])) {
                        map.put(can[i], map.get(can[i]) + 1);
                        k--;
                    }
                }
                for (Map.Entry<String,Integer> entry : map.entrySet()) {
                    System.out.println(entry.getKey() + " : " + entry.getValue());
                }
                System.out.println("Invalid : " + k);
            }
        }
}
全部评论

相关推荐

这是什么操作什么意思,这公司我服了...
斯派克spark:意思是有比你更便宜的牛马了
点赞 评论 收藏
分享
Lorn的意义:你这标个前端是想找全栈吗?而且项目确实没什么含金量,技术栈太少了,边沉淀边找吧 现在学院本想就业好一点四年至少得高三模式两年加油吧
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-11 11:29
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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