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))

你可能感兴趣的:(LeetCode)