• <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)
            大美女久久久久久j久久| 久久久久高潮毛片免费全部播放| 人妻精品久久久久中文字幕一冢本| 午夜精品久久久久久99热| 色综合久久88色综合天天| 久久久久国产一级毛片高清板| 亚洲欧美一区二区三区久久| 久久免费的精品国产V∧| 秋霞久久国产精品电影院| 久久只这里是精品66| 丁香狠狠色婷婷久久综合| A级毛片无码久久精品免费| 久久精品综合一区二区三区| 婷婷久久久亚洲欧洲日产国码AV | 久久久综合九色合综国产| 久久一区二区三区免费| 国产日韩欧美久久| 久久午夜无码鲁丝片| 久久久久亚洲?V成人无码| 久久久久人妻精品一区二区三区| 久久精品成人免费观看97| 丰满少妇高潮惨叫久久久| 91精品国产9l久久久久| 99精品久久久久久久婷婷| 无码任你躁久久久久久久| 久久久久国产一区二区三区| 国产产无码乱码精品久久鸭 | 国产无套内射久久久国产| 久久精品一本到99热免费| 亚洲伊人久久精品影院| 亚洲人成电影网站久久| 亚洲国产成人久久笫一页 | 久久久久久久久波多野高潮| 狠狠色丁香久久婷婷综合_中| 久久天天躁狠狠躁夜夜avapp| 精品人妻伦九区久久AAA片69 | 人妻无码精品久久亚瑟影视 | 久久久一本精品99久久精品88| 合区精品久久久中文字幕一区| 欧美久久亚洲精品| 久久久精品日本一区二区三区|