static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
vector<int> findErrorNums(vector<int>& nums)
{
int sz=nums.size();
vector<int> help(sz+,);
for(int i:nums)
help[i]++;
help[]=;
vector<int> res;
for(int i=;i<sz+;i++)
{
if(help[i]!=)
res.push_back(i);
}
if(help[res[]]==)
swap(res[],res[]);
return res;
}
};

扫一遍完事儿,简单粗暴

645. Set Mismatch的更多相关文章

  1. 448. Find All Numbers Disappeared in an Array&&645. Set Mismatch

    题目: 448. Find All Numbers Disappeared in an Array Given an array of integers where 1 ≤ a[i] ≤ n (n = ...

  2. 【Leetcode_easy】645. Set Mismatch

    problem 645. Set Mismatch 题意: solution1: 统计每个数字出现的次数了,然后再遍历次数数组,如果某个数字出现了两次就是重复数,如果出现了0次,就是缺失数. 注意:如 ...

  3. 645. Set Mismatch - LeetCode

    Question 645. Set Mismatch Solution 思路: 遍历每个数字,然后将其应该出现的位置上的数字变为其相反数,这样如果我们再变为其相反数之前已经成负数了,说明该数字是重复数 ...

  4. 645. Set Mismatch挑出不匹配的元素和应该真正存在的元素

    [抄题]: he set S originally contains numbers from 1 to n. But unfortunately, due to the data error, on ...

  5. leetcode 645. Set Mismatch——凡是要节约空间的题目 都在输入数据上下功夫 不要担心破坏原始的input

    The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...

  6. LeetCode 645. Set Mismatch (集合不匹配)

    The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...

  7. 【LeetCode】645. Set Mismatch 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Hash方法 直接计算 日期 题目地址: https ...

  8. Leetcode 之 Set Mismatch

    645. Set Mismatch 1.Problem The set S originally contains numbers from 1 to n. But unfortunately, du ...

  9. LeetCode All in One题解汇总(持续更新中...)

    突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对 ...

随机推荐

  1. leetcode937

    public class Solution { public string[] ReorderLogFiles(string[] logs) { var list1 = new List<str ...

  2. 新提示风格Hint BalloonHint 气泡

    Hint BalloonHint1新风格的提示,好看漂亮,对其他控件都起作用,TCSpinButton却不起作用XE7里也不行??Hint for (int i = 0; i < this-&g ...

  3. J2SE 8的输入输出--读取/写入文本文件和读取/写入二进制数据

    读取/写入文本文件 // 1. 文本输入 // (1) 短小文本直接转入字符串 String string = new String(Files.readAllBytes(Paths.get(&quo ...

  4. Git .gitignore使用 -- 过滤class文件或指定目录

    1. 进入当前的项目根目录 执行 git init touch .gitignore 2. 过滤class文件或指定目录 *.class /target/ 3. 提交 git add . 将所有文件提 ...

  5. svn异常处理

    TortoiseSVN 为客户端,SUBVersion为服务器端. 1.安装的tortoiseSVN不在鼠标右键菜单栏 出现这种原因是电脑的系统和svn不符,即电脑是64位系统,而svn是32位的. ...

  6. 使用webstorm创建vue项目

    进行vue开发首先需要配置node环境 配置好node环境在命令行中输入node -v npm -v则表示环境配置成功 在webstorm命令行中输入命令 1.安装脚手架 npm install -g ...

  7. UILabel 自适应高度,宽度

    mLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, 10, 1)]; mLabel1.text = @"my label 1, ...

  8. sessionStorage和localStorage

    html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage. sessionStorage用于本地存储一个会话(session)中的数据,这些数据只 ...

  9. jenkins systemctl启动失败

    centos yum或者rpm安装jenkins后起不来 vi /etc/init.d/jenkins candidates="/usr/local/jdk1.8.0_171/bin/jav ...

  10. 参数错误导致bug

    1.网站参数与数据库参数名字不一致(大小写). 2.参数漏掉一个字母(characterno写成了charaterno).