Leetcode: Contains Duplicate
2015-08-27 02:17
330 查看
Question
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.Solution
[code]class Solution(object): def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ hashset = set() for temp in nums: if temp not in hashset: hashset.add(temp) else: return True return False
相关文章推荐
- Leetcode: Factorial Trailing Zeroes
- ideaiu的使用
- CCComponentContainer,CCComponent解析
- 安装APK:Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
- 异常:org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 1) B. Minimization 贪心 dp
- LeetCode题解:Factorial Trailing Zeroes
- HDU2473 - Junk-Mail Filter 利用虚拟数组实现删除并查集的节点
- 【图论】【最小生成树】[IOI2003]maintain
- [捉虫记录]关于Cascade Training Error的bug
- failure during conversion to COFF: file invalid or corrupt
- 【HDOJ 1021】 Fibonacci Again (矩阵快速幂(裸))
- HDOJ 2674 N!Again(找规律)
- 人工智能进入股市操盘获利巨大激荡股市
- See You Again
- B. Order Book------(Codeforces Round #317 [AimFund Thanks-Round] (Div. 2))
- A. Arrays------(Codeforces Round #317 [AimFund Thanks-Round] (Div. 2))
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 1) A. Lengthening Sticks 分类
- 1.2句柄及 WinMain函数
- ACdream 1420 High Speed Trains(容斥原理)