位操作 O(n)
class Solution: # @param {integer[]} nums # @return {boolean} def containsDuplicate(self, nums): pos, neg = 0, 0 for x in nums: if x < 0: temp = 1 << -x if neg & temp != 0: return True pos |= temp else: temp = 1 << x if pos & temp != 0: return True pos |= temp return False
哈希表 O(n)
Python一行
2024年2月28日 00:12
I have always loved research and it's been actually the cause of my successful finding about all the fun things to do. I used to be doing a search on the net, I discovered a wonderful post regarding the subject of the article thatt I will have to share with your followers. Don't have any ideas for holiday? There are plenty of things to do post around your location that you can find there.