题解 | #序列找数#

序列找数

http://www.nowcoder.com/practice/a7d1856a72404ea69fdfb5786d65539c

import java.util.*;
public class Main{
    public static void main(String[] args) {
        setTest();
    }
    public static void setTest() {
        Set<Integer> tmpSet = new HashSet<>();
        Set<Integer> collect = new HashSet<>();
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i <= n; i++) {
            collect.add(i);
        }
        for (int i = 0; i < n; i++) {
            int item = scanner.nextInt();
            tmpSet.add(item);
        }

        collect.removeAll(tmpSet);
        collect.stream().forEach(System.out::println);
    }
}
全部评论

相关推荐

01-30 09:45
燕山大学 Java
喵_coding:这种直接跑就完事了 哪有毕业了才签合同 任何offer和三方都没有的
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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