class CountingBloomFilter:
"""
@param: k: An integer
"""
def __init__(self, k):
# do intialization if necessary
self.k = k
self.container = collections.defaultdict(int)
"""
@param: word: A string
@return: nothing
"""
def add(self, word):
# write your code here
self.container[word] += 1
"""
@param: word: A string
@return: nothing
"""
def remove(self, word):
# write your code here
if self.container[word] >= 1:
self.container[word] -= 1
"""
@param: word: A string
@return: True if contains word
"""
def contains(self, word):
# write your code here
if self.container[word] == 0:return False
return True
Lintcode 555 · Counting Bloom Filter [Python]
最新推荐文章于 2022-03-17 13:52:00 发布