• <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| 久久精品国产清自在天天线| 办公室久久精品| 久久WWW免费人成—看片| 久久只这里是精品66| 久久久久黑人强伦姧人妻| 久久久久久噜噜精品免费直播| 亚洲国产精久久久久久久| 久久精品亚洲精品国产欧美| 色婷婷久久久SWAG精品| 久久国产高清字幕中文| 久久久国产99久久国产一| 久久亚洲精品人成综合网| 久久精品18| 久久久久AV综合网成人| 97久久国产露脸精品国产| 91久久福利国产成人精品| 久久www免费人成看片| 蜜臀久久99精品久久久久久| 亚洲AV日韩AV天堂久久| 久久午夜免费视频| 国内精品伊人久久久久网站| 色婷婷综合久久久中文字幕| 亚洲国产综合久久天堂| 欧美国产成人久久精品| 国产精品久久久久久久久鸭 | 久久超碰97人人做人人爱| 久久93精品国产91久久综合| 国产精品免费福利久久| 精品久久人妻av中文字幕| 久久亚洲熟女cc98cm| 婷婷国产天堂久久综合五月| 99久久国产综合精品网成人影院 | 99国产欧美精品久久久蜜芽| 久久99热这里只有精品国产| 色老头网站久久网| 久久婷婷色香五月综合激情| 久久综合久久性久99毛片| 人人狠狠综合久久亚洲婷婷| 国产成人精品综合久久久| 国产成人久久激情91|