Contains Duplicate
2015-12-09 16:18
495 查看
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
int length = nums.size();
sort(nums.begin(),nums.end());//比较相等的数据可以先对数组进行排序
for (int i =0;i<length-1 ;i++)
{ if(nums[i]==nums[i+1])
return true;
}
return false;
}
};
相关文章推荐
- Esper系列(十四)Contained-Event Selection
- ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
- select的5中子句where,group by, havaing, order by, limit的使用顺序及实例
- Drainage Ditches
- Foxmail管理多个邮箱
- Microsoft Azure Tools: Failed to initialize Microsoft Azure storage emulator. The storage emulator n
- 关于contain_of的理解
- 调用打电话,调用发短信,发email,打开网址,打开其他第三方应用
- 创建虚拟机libvirt报错 Fail bind socket:Permission Deny
- 2014/08/23——OJ出现waiting...
- saiku中多cube排序问题
- saiku中默认级别all的国际化
- BeginPaint和GetDC的区别
- 让ubuntu开机快一点:记开机出现Waiting for network configuration...
- Daily Scrum NO.2
- AIM documentation templates
- 更新Xcode7之后报错: Assertion failure
- leetcode -- Climbing Stairs -- 简单重要
- xtrabackup版本较低触发nfs-v4的bug:cp: failed to preserve ownership: Invalid argument
- zzulioj 1809: make pair (数学转换求余简化)