• <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)
            一本一道久久综合狠狠老| 久久久久99精品成人片欧美| 一本久久综合亚洲鲁鲁五月天| 亚洲国产成人久久精品动漫| 亚洲国产另类久久久精品| 麻豆久久久9性大片| 久久丫忘忧草产品| 久久久久亚洲av无码专区喷水| 久久天天躁狠狠躁夜夜躁2O2O | 久久男人中文字幕资源站| 久久精品国产一区二区三区| 亚洲狠狠久久综合一区77777| 日韩亚洲欧美久久久www综合网| 精品久久久久久久中文字幕| 亚洲国产精品久久久久婷婷软件| 久久精品中文字幕一区| 久久久国产打桩机| 久久精品国产精品亚洲人人 | 国产午夜精品理论片久久| 亚洲国产成人久久综合一区77| 国产色综合久久无码有码| 91精品国产9l久久久久| 女同久久| 国产高潮国产高潮久久久91 | 亚洲伊人久久综合影院| 久久久国产乱子伦精品作者| 丰满少妇人妻久久久久久| 青青热久久国产久精品 | 波多野结衣久久一区二区 | 久久本道久久综合伊人| 性欧美丰满熟妇XXXX性久久久 | 久久久精品波多野结衣| 久久精品中文字幕无码绿巨人| 久久久WWW免费人成精品| 久久夜色精品国产噜噜麻豆| segui久久国产精品| 久久99国产精品久久99| 久久WWW免费人成一看片| 午夜精品久久久久久| 久久国产成人午夜aⅴ影院| 久久久久亚洲av无码专区导航|