leetcode645
vector<int> findErrorNums(vector<int>& nums) {
const int N = ;
int S[N];
int n = nums.size();
for (int i = ; i < N; i++)
{
S[i] = ;
}
for (int i = ; i <= n; i++)
{
int m = nums[i - ];
S[m]++;
}
int dup = -;
int miss = -;
for (int i = ; i <= n; i++)
{
if (S[i] == && dup == -)
{
dup = i;
}
if (S[i] == && miss == -)
{
miss = i;
}
}
vector<int> R;
R.push_back(dup);
R.push_back(miss);
return R;
}
leetcode645的更多相关文章
- [Swift]LeetCode645. 错误的集合 | 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
The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...
- Leetcode645.Set Mismatch错误的集合
集合 S 包含从1到 n 的整数.不幸的是,因为数据错误,导致集合里面某一个元素复制了成了集合里面的另外一个元素的值,导致集合丢失了一个整数并且有一个元素重复. 给定一个数组 nums 代表了集合 S ...
随机推荐
- 内核编译错误解答(elf_i386错误)
内核编译错误解答(elf_i386错误) 在编译内核过程中遇到的问题及解决方法: 1.root@org:/usr/src/linux# make menuconfig *** Unable to f ...
- Springboot- pagehelper使用
1.添加pagehelper依赖 <dependency> <groupId>org.github.pagehelper</groupId> <artifac ...
- 图片放大器——wpf
<Grid> <Image x:Name="imgSource" Source="{Binding Web ...
- vs plug
工欲善其事,必先利其器.尽管visual studio本身已经非常强大,但优秀的插件仍然可以帮开发者大大提高效率,以下是牛牛非常喜欢的vs插件. 1.Indent Guides 绝对是必须的,有了这些 ...
- MySQL 索引知识整理(创建高性能的索引)
前言: 索引优化应该是对查询性能优化的最有效的手段了.索引能够轻易将查询性能提高几个数量级. // 固态硬盘驱动器有和机械硬盘启动器,有着完全不同的性能特性: 然而即使是固态硬盘,索引的原则依然成立, ...
- xss攻击的分类
1.反射型XSS 原理: 通过在页面上植入恶意链接,诱使用户点击,执行js脚本,所谓反射型XSS就是将用户输入的数据(恶意用户输入的js脚本),“反射”到浏览器执行. 实例: php源码: <? ...
- 2017.11.27 stm8 low power-consumption debugging
1 STM8L+LCD The STM8L-DISCOVERY helps you to discover the STM8L ultralow power features and todevelo ...
- listening 1
It was regrettable that such great issues had to be the thrust and parry of a general election. But ...
- 加密算法之BLOWFISH算法
加密信息 BlowFish算法用来加密64Bit长度的字符串. BlowFish算法使用两个"盒"--ungignedlongpbox[18]和unsignedlongsbox[4 ...
- Django ImageField 上传图片并保存到数据库
转自:http://logic0.blog.163.com/blog/static/188928146201371235435974/ Form代码: class ImageUploadForm(fo ...