(LeetCode)Contains Duplicate -- 查看数组是否重复
2016-07-26 09:34
381 查看
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.
Subscribe to see which companies asked this question
解题分析:
题目过于简单,判断数组中是否有重复的。
Subscribe to see which companies asked this question
解题分析:
题目过于简单,判断数组中是否有重复的。
# -*- coding:utf-8 -*- __author__ = 'jiuzhang' class Solution(object): def containsDuplicate(self, nums): return len(nums) != len(set(nums)) ''' 测试部分 nums = [2,2, 3, 4, 5, 6] S = Solution() a = S.containsDuplicate(nums) print a '''
相关文章推荐
- hihocoder #1341 Constraint Checker
- 杭电-1702 ACboy needs your help again!(栈&队列)
- POJ1363:Rails(栈)
- poj 1363 Rails 【栈】
- Repair the Wall
- 2016 Multi-University Training Contests
- What it means for machine intelligence and AI-Christopher Nguyen
- 【 POJ 1363 】Rails
- LeetCode:Contains Duplicate
- tail、head 命令用法
- POJ:1702 Rails(栈的应用)
- HDU:1702 ACboy needs your help again!(简单栈、队列)
- 服务器TIME_WAIT和CLOSE_WAIT详解和解决办法
- poj1363Rails(栈)
- 【POJ 1363】Rails
- 【HDU 杭电 1702】ACboy needs your help again!
- Codeforces Round #209 (Div. 2) D - Pair of Numbers
- 2016 Multi-University Training Contest 2 题解(待续)
- 66. No EntityManager with actual transaction available for current thread【从零开始学】
- 【转载】重磅!中国人工智能/机器人/无人机创业公司100 | 智能内参