217. Contains Duplicate
2016-02-25 01:32
447 查看
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least
twice in the array, and it should return false if every element is distinct.
twice in the array, and it should return false if every element is distinct.
class Solution { public: bool containsDuplicate(vector<int>& nums) { std::sort(nums.begin(),nums.end()); for(int i=1;i<nums.size();++i) if(nums[i]==nums[i-1]) return true; return false; } };
相关文章推荐
- Does Daemon Thread Exit with Main Thread?
- Exchange2010使用 Export-Mailbox cmdlet 将邮箱的内容移动到指定的邮箱文件夹
- HDU 3264 Open-air shopping malls(计算几何 && 二分优化)
- hdu2467 String painter(区间dp)
- UVA253 Cube painting
- Zookeeper异常:FAILED TO WRITE PID与Permission denied
- Container With Most Water
- AIDL随写
- 高僧斗法--Staircase Nim
- poj 1363 Rails(栈)
- 【bzoj2434】[Noi2011]阿狸的打字机 AC自动机+fail树+dfs序+树状数组
- 欢迎使用CSDN-markdown编辑器
- How Does Caching Work in AFNetworking? : AFImageCache & NSUrlCache Explained
- 【bzoj3172】[Tjoi2013]单词 AC自动机+fail树
- leetcode笔记:Contains Duplicate II
- 模型选择准则之AIC和BIC
- AIDL
- STM32 Keil仿真进不了Main()函数
- leetcode笔记:Contains Duplicate
- if __name__ == '__main__':