Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤). Then N integers are given in the next line, separated by spaces. All the numbers are in the range of int.

Output Specification:

Print in a line the smallest positive integer that is missing from the input list.

Sample Input:

10
5 -25 9 6 1 3 4 2 5 17

Sample Output:

7
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<int,bool>mp;
int main(){
int N;
scanf("%d", &N);
for(int i = ; i < N; i++){
int num;
scanf("%d", &num);
if(num > ){
mp[num] = true;
}
}
for(long long i = ; i < ; i++){
if(mp.count(i) == ){
printf("%lld", i);
break;
}
}
cin >> N;
return ;
}

A1144. The Missing Number的更多相关文章

  1. PAT A1144 The Missing Number (20 分)——set

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

  2. PAT_A1144#The Missing Number

    Source: PAT A1144 The Missing Number (20 分) Description: Given N integers, you are supposed to find ...

  3. Leetcode-268 Missing Number

    #268.  Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...

  4. Missing number

    Missing number 题目: Description There is a permutation without two numbers in it, and now you know wh ...

  5. 【LeetCode】268. Missing Number

    Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...

  6. hdu 5166 Missing number

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5166 Missing number Description There is a permutatio ...

  7. Missing Number, First Missing Positive

    268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find th ...

  8. HDU 5166 Missing number 简单数论

    Missing number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) [ ...

  9. Missing number in array

    Given an array of size n-1 and given that there are numbers from 1 to n with one missing, the missin ...

随机推荐

  1. bootStrap的使用

    1.首先要打开bootstrap的官网 点进去 2你会看到下面这样一个页面里面有很多组件 这里面的代码是实现组件功能的核心代码,还不能直接使用,要引入相关的js css 我们要在起步中下载相关的页面下 ...

  2. Python魔法方法(magic method)细解几个常用魔法方法(下)

    接上文,再介绍最后几个常用的魔法方法. 关于__dict__: 先上个例子: class Test(object): fly = True def __init__(self, age): self. ...

  3. 对于tomcat通过catalina.sh停止服务后,tomcat进程没有退出问题解决办法

    例:tomcat路径及名称为/data/apache-tomcat-7.0.67/ vim /data/apache-tomcat-7.0.67/bin/catalina.sh 找到org.apach ...

  4. Java 8 函数式接口

    函数式接口(Functional Interface)就是一个有且仅有一个抽象方法,但是可以有多个非抽象方法的接口. 函数式接口可以被隐式转换为 lambda 表达式. Lambda 表达式和方法引用 ...

  5. Data Structures & js &ES 6 & ES next

    Data Structures & js &ES 6 & ES next Algorithm Singly-Linked List & Doubly-Linked Li ...

  6. github & markdown & collapse & table

    github & markdown collapse & table https://github.com/Microsoft/TypeScript/issues/30034 GitH ...

  7. 集合之HashSet(含JDK1.8源码分析)

    一.前言 我们已经分析了List接口下的ArrayList和LinkedList,以及Map接口下的HashMap.LinkedHashMap.TreeMap,接下来看的是Set接口下HashSet和 ...

  8. HTML中文本过长时自动隐藏末尾部分或中间等任意部分

    一.    一般情况下,HTML字符串过长时都会将超过的部分隐藏点,方法如下: 设置CSS: .ellipsis-type{ max-width: 50px;                      ...

  9. Vue学习目录

    前面的话 近年来,前端框架发展火热,新的框架和名词不停地出现在开发者眼前,而且开发模式也产生了一定的变化.目前来看,前端MVVM框架的出现给开发者带来了不小的便利,其中的代表就有Angular.js. ...

  10. 我的代码库-Java8实现FTP与SFTP文件上传下载

    有网上的代码,也有自己的理解,代码备份 一般连接windows服务器使用FTP,连接linux服务器使用SFTP.linux都是通过SFTP上传文件,不需要额外安装,非要使用FTP的话,还得安装FTP ...