LRUCache leetcode146

数据结构极客视频7

class LRUCache:

    def __init__(self, capacity: int):
        self.remain=capacity
        self.dic=collections.OrderedDict()
        

    def get(self, key: int) -> int:
        if key not in self.dic:
            return -1
        v = self.dic.pop(key)
        self.dic[key]=v
        return v

    def put(self, key: int, value: int) -> None:    
        if key in self.dic:
            self.dic.pop(key)
        
        else:            
            if self.remain>0:
                self.remain-=1
            else:
                self.dic.popitem(last=False)        
        self.dic[key]=value

布隆过滤器

数据结构极客视频7

课程总结

模板

递归模板

数据结构极客视频7

DFS

数据结构极客视频7

BFS

数据结构极客视频7

二分查找

数据结构极客视频7

DP模板

数据结构极客视频7

位运算

数据结构极客视频7

切题

数据结构极客视频7
数据结构极客视频7

斐波那契序列 改到O(n)方法

数据结构极客视频7

相关文章:

  • 2022-12-23
  • 2021-12-14
  • 2021-07-02
  • 2022-01-02
  • 2021-11-16
  • 2021-06-05
  • 2021-07-27
猜你喜欢
  • 2021-08-23
  • 2021-11-13
  • 2021-10-28
  • 2021-08-20
  • 2021-12-23
  • 2021-05-27
  • 2022-01-06
相关资源
相似解决方案