645. Set Mismatch
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的更多相关文章
- 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 = ...
- 【Leetcode_easy】645. Set Mismatch
problem 645. Set Mismatch 题意: solution1: 统计每个数字出现的次数了,然后再遍历次数数组,如果某个数字出现了两次就是重复数,如果出现了0次,就是缺失数. 注意:如 ...
- 645. Set Mismatch - LeetCode
Question 645. Set Mismatch Solution 思路: 遍历每个数字,然后将其应该出现的位置上的数字变为其相反数,这样如果我们再变为其相反数之前已经成负数了,说明该数字是重复数 ...
- 645. Set Mismatch挑出不匹配的元素和应该真正存在的元素
[抄题]: he set S originally contains numbers from 1 to n. But unfortunately, due to the data error, on ...
- leetcode 645. Set Mismatch——凡是要节约空间的题目 都在输入数据上下功夫 不要担心破坏原始的input
The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...
- LeetCode 645. Set Mismatch (集合不匹配)
The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...
- 【LeetCode】645. Set Mismatch 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Hash方法 直接计算 日期 题目地址: https ...
- Leetcode 之 Set Mismatch
645. Set Mismatch 1.Problem The set S originally contains numbers from 1 to n. But unfortunately, du ...
- LeetCode All in One题解汇总(持续更新中...)
突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对 ...
随机推荐
- oracle imp dmp
windows>cmd> imp userid=用户名/密码@orcl file=d:\nc60.dmp full=y imp userid=SYSTEM/password@orcl fi ...
- VBA 打开带密码的文件
' 打开文件 ROSE 为只读密码 CHECK 为编辑密码 Set wb = Workbooks.Open(file, 0, True, , "ROSE", "CH ...
- Pycharm安装autopep8工具
参考文当:https://www.cnblogs.com/heenhui2016/p/6802122.html
- 搭建turbine时 hystrix MaxConcurrentConnections reached 异常
2017-03-28 10:04:47.438 ERROR 1035 --- [InstanceMonitor] c.n.t.monitor.instance.InstanceMonitor : Co ...
- 没有装delphi软件则须修改程序的Uses单元,去掉QDialogs qtintf.dll
转: 花了几天的功夫,终于完成了一个delphi调用webservice(C#)的任务,发现了好多问题,不过还是解决了,和大家分享一下.首先,就是调用时一个问题,如果你的webservice没有数据库 ...
- EasyUI多选的获取
function deletePRE() { var rows = $('#dg').datagrid('getSelections'); var ids = []; var other_ids = ...
- SharePoint 2010 图表控件
需求: 统计每周的事件创建数量及关闭数量 以折线的形式显示 一张图表显示两条折线 知识点: 图表控件的使用 外部内容类型 数据库(sql)view(数据源) 结果:
- 使用ecstore-sdk开发包制作易开店和启明星模板
前言: 尽管商派官网有模板开发教程,但是诸多方面太过笼统.我等平庸之辈,纵使细心研读,潜心修炼,亦未能品味练功境界,领悟其中真谛. 商派有云,此九阳真经不用您挥刀****本人却感觉此教程令人抓狂,无人 ...
- .NET中的文件IO操作实例
1.写入文件代码: //1.1 生成文件名和设置文件物理路径 Random random = new Random(DateTime.Now.Millisecond); ); string Physi ...
- 关于Python的OSError和IOError
参考:http://stackoverflow.com/questions/29347790/difference-between-ioerror-and-oserror 在3.x版本已经移除,剩下O ...