class Solution(object): def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ return len(nums) != len(set(nums))
Nice python way tho.
However, it actually did more work than others' common code. Their process would mostly did less iterations, thus ending sooner than yours. You don't necessarily form up the whole set.
@facss As long as its still O(n), it matters not that much...
@facss Agree. The code is short but it's unnecessary slow. I think it's a bad sample if it's for real production.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.