We can use set in Python, which has the feature of getting rid of duplicate automatically.
Solution:
# T:O(n) S:O(n) class Solution: # @param {integer[]} nums # @return {boolean} def containsDuplicate(self, nums): return len(nums) > len(set(nums))Run Time: 80 ms
No comments:
Post a Comment