您的位置:首页 > 编程语言 > Python开发

LeetCode OJ 系列之217 Contains Duplicate --Python

2015-11-23 14:30 603 查看
Problem:

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.

Answer:

class Solution(object):
def containsDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
if len(set(nums)) != len(nums):
return True
return False
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  LeetCode Python OJ