【1144】The Missing Number (20 分)

简介: 【1144】The Missing Number (20 分)【1144】The Missing Number (20 分)
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>  
#include<map>
#include<vector>
#include<queue> 
using namespace std;  
int main(){   
  int n,a,num=0;
  cin >> n;
  map<int,int> m;
  for(int i=0;i<n;i++){
    cin >> a;
    m[a]++;//map存储每个数字出现的次数
  }
  while(++num) //注意此处是先加1
    if( m[num] == 0 ) break;
  cout << num;
  system("pause");
    return 0;   
}
相关文章
|
C++ 容器
【PAT甲级 - C++题解】1144 The Missing Number
【PAT甲级 - C++题解】1144 The Missing Number
74 0
|
算法
LeetCode 268. Missing Number
给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数。
101 0
LeetCode 268. Missing Number
LeetCode之Missing Number
LeetCode之Missing Number
100 0
|
算法
LeetCode 268 Missing Number(丢失的数字)
版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/50768898 翻译 给定一个包含从0,1,2...,n中取出来的互不相同的数字,从数组中找出一个丢失的数字。
1013 0
|
索引
Missing number - 寻找缺失的那个数字
需求:给出一个int型数组,包含不重复的数字0, 1, 2, ..., n;找出缺失的数字; 如果输入是[0, 1, 2] 返回 3  输入数组 nums = [0, 1, 2, 4] ;应该返回 3 输入nums = [2, 0] ;应该返回 1 输入nums = [1, 0];应该返回 ...
853 0
|
机器学习/深度学习 移动开发
[LeetCode] Missing Number
There are three methods to solve this problem: bit manipulation, rearrangement of the array, and math tricks.
670 0
|
Java C++
[LeetCode] Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm
1085 0
|
8月前
|
存储 SQL 算法
LeetCode 题目 65:有效数字(Valid Number)【python】
LeetCode 题目 65:有效数字(Valid Number)【python】
|
9月前
|
存储 算法
【LeetCode力扣】单调栈解决Next Greater Number(下一个更大值)问题
【LeetCode力扣】单调栈解决Next Greater Number(下一个更大值)问题
72 0