【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
45 0
|
算法
LeetCode 268. Missing Number
给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数。
69 0
LeetCode 268. Missing Number
LeetCode之Missing Number
LeetCode之Missing Number
72 0
|
算法
LeetCode 268 Missing Number(丢失的数字)
版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/50768898 翻译 给定一个包含从0,1,2...,n中取出来的互不相同的数字,从数组中找出一个丢失的数字。
977 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
1063 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];应该返回 ...
823 0
|
机器学习/深度学习 移动开发
[LeetCode] Missing Number
There are three methods to solve this problem: bit manipulation, rearrangement of the array, and math tricks.
650 0
|
8月前
|
算法
Leetcode 313. Super Ugly Number
题目翻译成中文是『超级丑数』,啥叫丑数?丑数就是素因子只有2,3,5的数,7 14 21不是丑数,因为他们都有7这个素数。 这里的超级丑数只是对丑数的一个扩展,超级丑数的素因子不再仅限于2 3 5,而是由题目给定一个素数数组。与朴素丑数算法相比,只是将素因子变了而已,解法还是和朴素丑数一致的。
73 1
|
21天前
|
存储 SQL 算法
LeetCode 题目 65:有效数字(Valid Number)【python】
LeetCode 题目 65:有效数字(Valid Number)【python】