mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
<ul>
|
||||
<li><code>LRUCache(int capacity)</code> Initialize the LRU cache with <strong>positive</strong> size <code>capacity</code>.</li>
|
||||
<li><code>int get(int key)</code> Return the value of the <code>key</code> if the key exists, otherwise return <code>-1</code>.</li>
|
||||
<li><code>void put(int key, int value)</code> Update the value of the <code>key</code> if the <code>key</code> exists. Otherwise, add the <code>key-value</code> pair to the cache. If the number of keys exceeds the <code>capacity</code> from this operation, <strong>evict</strong> the least recently used key.</li>
|
||||
<li><code>void put(int key, int value)</code> Update the value of the <code>key</code> if the <code>key</code> exists. Otherwise, add the <code>key-value</code> pair to the cache. If the number of keys exceeds the <code>capacity</code> from this operation, <strong>evict</strong> the least recently used key.</li>
|
||||
</ul>
|
||||
|
||||
<p>The functions <code data-stringify-type="code">get</code> and <code data-stringify-type="code">put</code> must each run in <code>O(1)</code> average time complexity.</p>
|
||||
<p>The functions <code>get</code> and <code>put</code> must each run in <code>O(1)</code> average time complexity.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input</strong>
|
||||
@@ -40,5 +40,5 @@ lRUCache.get(4); // return 4
|
||||
<li><code>1 <= capacity <= 3000</code></li>
|
||||
<li><code>0 <= key <= 10<sup>4</sup></code></li>
|
||||
<li><code>0 <= value <= 10<sup>5</sup></code></li>
|
||||
<li>At most 2<code> * 10<sup>5</sup></code> calls will be made to <code>get</code> and <code>put</code>.</li>
|
||||
<li>At most <code>2 * 10<sup>5</sup></code> calls will be made to <code>get</code> and <code>put</code>.</li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user