LeetCode#217 Contains Duplicate

Problem Definition:

  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: 一行解决战斗

1 class Solution:
2     # @param {integer[]} nums
3     # @return {boolean}
4     def containsDuplicate(self, nums):
5         return len(nums)!=len(set(nums))
posted @ 2015-07-16 17:14  曾可爱  阅读(77)  评论(0编辑  收藏  举报