• <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)
            久久精品国产一区二区三区 | 亚洲AV日韩AV永久无码久久| 国产巨作麻豆欧美亚洲综合久久| 久久本道伊人久久| 久久高潮一级毛片免费| 欧美激情精品久久久久久| 国产精品乱码久久久久久软件| 少妇无套内谢久久久久| 国产精品久久久久影院色| 国产成人精品久久| 久久久久久精品无码人妻| 久久精品国产亚洲麻豆| 噜噜噜色噜噜噜久久| 狠狠色噜噜狠狠狠狠狠色综合久久| 婷婷五月深深久久精品| 久久国产精品久久精品国产| 日韩AV毛片精品久久久| 久久人人爽人人爽人人AV东京热| 99久久99这里只有免费的精品| 国内精品免费久久影院| 青青草原精品99久久精品66| 91久久精品视频| 麻豆一区二区99久久久久| 成人亚洲欧美久久久久| 亚洲精品国产字幕久久不卡| 国内精品伊人久久久久网站| 伊人久久久AV老熟妇色| 国产激情久久久久影院| 欧美黑人激情性久久| 伊人伊成久久人综合网777| 国产一久久香蕉国产线看观看| 2019久久久高清456| 久久人人爽人爽人人爽av| 久久九九精品99国产精品| 欧美亚洲国产精品久久高清| 久久综合九色综合精品| 久久国产乱子伦免费精品| 成人午夜精品无码区久久| 亚洲天堂久久久| 久久久国产99久久国产一| 色综合久久中文字幕综合网|