标签:duplicate site img def 方法 mic col int ted
题目描述:
第一次提交:
class Solution: def containsDuplicate(self, nums: List[int]) -> bool: nums2 = set(nums) return not len(nums2)==len(nums)
方法二:哈希表
class Solution: def containsDuplicate(self, nums: List[int]) -> bool: visited = set() for num in nums: if num in visited:return True visited.add(num) return False
方法三:排序
标签:duplicate site img def 方法 mic col int ted
原文地址:https://www.cnblogs.com/oldby/p/11621429.html