• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Uriel's Corner

            Research Associate @ Harvard University / Research Interests: Computer Vision, Biomedical Image Analysis, Machine Learning
            posts - 0, comments - 50, trackbacks - 0, articles - 594
            模擬LRU Cache,用python的OrderedDict極度適合!


             1 #146
             2 #Runtime: 990 ms (Beats 30.89%)
             3 #Memory: 78.8 MB (Beats 74.63%)
             4 
             5 class LRUCache(object):
             6 
             7     def __init__(self, capacity):
             8         """
             9         :type capacity: int
            10         """
            11         self.cap = capacity
            12         self.cache = OrderedDict()
            13         
            14 
            15     def get(self, key):
            16         """
            17         :type key: int
            18         :rtype: int
            19         """
            20         if key not in self.cache:
            21             return -1
            22         v = self.cache.pop(key)
            23         self.cache[key] = v
            24         return v
            25         
            26 
            27     def put(self, key, value):
            28         """
            29         :type key: int
            30         :type value: int
            31         :rtype: None
            32         """
            33         if key in self.cache:
            34             self.cache.pop(key)
            35         elif len(self.cache) == self.cap:
            36             self.cache.popitem(last=False)
            37         self.cache[key] = value
            38         
            39 
            40 
            41 # Your LRUCache object will be instantiated and called as such:
            42 # obj = LRUCache(capacity)
            43 # param_1 = obj.get(key)
            44 # obj.put(key,value)
            久久久精品久久久久久| 俺来也俺去啦久久综合网| 精品国产综合区久久久久久 | 久久精品亚洲精品国产欧美| 久久久久久A亚洲欧洲AV冫| 精品久久久久久国产| 久久久久综合网久久| 中文精品久久久久人妻| 久久久久国产一级毛片高清版| 久久人人爽人人精品视频| 亚洲精品无码久久久久sm| 99久久国产综合精品成人影院| 久久综合偷偷噜噜噜色| 国产精品美女久久久| 久久天天躁夜夜躁狠狠| 国产精品久久久久一区二区三区 | 久久99精品久久久久久| 久久人人爽人人人人片av| 国产精品青草久久久久福利99 | 久久久久国产一区二区| 国产美女久久精品香蕉69| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 久久免费高清视频| 天天躁日日躁狠狠久久| 久久青青草视频| 99久久久久| 久久久久久免费一区二区三区| 亚洲中文字幕无码久久精品1 | 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 国产国产成人精品久久| 伊人久久大香线蕉AV色婷婷色| 人人狠狠综合久久亚洲| 国产成人久久精品二区三区| 精品蜜臀久久久久99网站| 久久婷婷五月综合国产尤物app| 婷婷久久综合九色综合九七| 成人国内精品久久久久影院VR| 波多野结衣中文字幕久久| 国产精品美女久久久久久2018| 精品久久久久中文字幕日本| 中文字幕久久精品 |