LeetCode *** 217. Contains Duplicate
2016-04-06 19:12
369 查看
题目:
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.
分析:
查找是否有重复元素,那么可以利用set来完成这道题目。
代码:
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.
分析:
查找是否有重复元素,那么可以利用set来完成这道题目。
代码:
class Solution { public: bool containsDuplicate(vector<int>& nums) { return set<int>(nums.begin(),nums.end()).size()<nums.size(); } };
相关文章推荐
- zoj 1094 Matrix Chain Multiplication
- aircarck-ng
- RAII和模拟实现智能指针
- 微软CEO 纳德拉将赌注押在人工智能上
- Grails如何启动Debug模式
- http://blog.csdn.net/lmj623565791/article/details/39122981
- http://blog.csdn.net/lmj623565791/article/details/39121377
- RAID 磁盘状态为foreign,怎么变成ready
- dell r710 服务器配置RAID5(3块硬盘做RAID5,另外再弄一块做数据冗余盘)
- Apache问题解决:httpd: Could not reliably determine the server's fully qualified domain name
- canvas.drawText(string, xPos, yPos, paint)文本居中的办法
- Mac OS 安装tensorflow RuntimeError: Broken toolchain: cannot link a simple C program
- 1106. Lowest Price in Supply Chain (25) 树的遍历,DFS
- 解决"initialization failure:0×0000000c"和"txwebserver遇到未知错误"
- 51nod1305 Pairwise Sum and Divide
- AIDL 实现 IPC(进程间通信)
- Assertion failure layoutSublayersOfLayer:], /SourceCache
- dubbo服务无法注册问题 Failed to subscribe consumer:// 解决方法
- 随记(十)--'xxx' does not contain bitcode报错
- LeetCode Container With Most Water