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. Appium清空EditText

    在使用appium过程中,发现sendkeys和clear方法并不太好使,封装模拟手工一个一个删除 这里用到keyEvent,具体内容请参考api http://appium.github.io/ja ...

  2. sssp-webservce_restful

    pom <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.or ...

  3. FireFox 火狐主页被劫持

    火狐主页被劫持hao123,流氓 WIN7 ,firefox,任务栏,快速启动,右键 属性 target 应该是 "D:\Program Files (x86)\Mozilla Firefo ...

  4. Spring boot&Mybatis 启动报错 Failed to auto-configure a DataSource

    *************************** APPLICATION FAILED TO START *************************** Description: Fai ...

  5. JS 报表制作

    1:Echarts, 界面多样化. http://echarts.baidu.com/index.html 2: Jmgraph 工具 简单的画线工具 http://graph.jm47.com/ 3 ...

  6. String类的intern()方法

    0.引言 什么都先不说,先看下面这个引入的例子: String str1 = new String("SEU")+ new String("Calvin"); ...

  7. 获取tomcat源码

    1.安装环境 工欲善其事必先利其器,在开始工作之前,先准备好环境和工具:jdk.eclipse.并配置eclipse的svn插件.ant,具体怎么配置就不说了,网上都有. 2.下载源码 打开eclip ...

  8. Swift 4 新特性

    多行字符串 /// 多行字符串用三引号括起来 let quotation = """ The White Rabbit put on his spectacles. &q ...

  9. 数据类型-Series

    数据类型-Series Series数据类型由一组数据和数据相关的索引组成,键 -> 值 Series数据类型可视为:一维 带标签 数组 Series基本操作类似数组和字典 Series数据类型 ...

  10. oracle与DB2

    1.体系结构,DB2的实例和数据库分开的做法,我个人还是比较喜欢的,因为实例可以创建多个,数据库的恢复直接恢复到实例下就可以了,相对ORACLE简单多了. 2.管理工具,DB2的管理工具做得太简陋了, ...