[Leetcode]217. Contains Duplicate
2016-06-06 22:28
411 查看
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) {
set<int> se(nums.begin(),nums.end());
return se.size()!=nums.size()? true:false;
}
};
用set来解答,很简单。
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
set<int> se(nums.begin(),nums.end());
return se.size()!=nums.size()? true:false;
}
};
相关文章推荐
- Neo4j索引笔记之SchemaIndex和LegacyIndex
- 193_AIDL的使用
- Grails用CONSOLE测试,比写集成测试还快
- vector中pair的排序方法
- 196. Delete Duplicate Emails
- [转载] fail-fast总结(通过ArrayList来说明fail-fast的原理、解决办法)
- Rails中force index
- TIME_WAIT状态存在的必要性
- Ex2010-17 Linked Mailbox in Exchange Server
- __stack_chk_fail栈检查失败
- return columns.All(new Func<string, bool>(list.Contains));
- Ex2010-16 Connect Users On Child Domain to Exchange On Root Domain
- scala之trait详解三:延时绑定
- Exchange 2010 PS 之new-mailboxDatabase&Get-MailboxDatabase&Move-databasePath!
- 设计模式笔记-Chain of Responsibility职责链模式
- systemtap分析软raid io拆分问题
- wait(),notify(),notifyAll()进行了详细的分析介绍
- iOS之蓝牙开发—何时触发(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral方法
- hdu 1023 Train Problem II
- 比Android更深远的改变世界——谷歌开源人工智能系统TensorFlow文档中文版