1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 19:31:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part2

This commit is contained in:
2022-03-27 20:38:29 +08:00
parent 5a4fa6db12
commit 0fc7f4b734
1617 changed files with 134637 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<p>请定义一个队列并实现函数 <code>max_value</code> 得到队列里的最大值,要求函数<code>max_value</code><code>push_back</code><code>pop_front</code><strong>均摊</strong>时间复杂度都是O(1)。</p>
<p>若队列为空,<code>pop_front</code><code>max_value</code>&nbsp;需要返回 -1</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>
[&quot;MaxQueue&quot;,&quot;push_back&quot;,&quot;push_back&quot;,&quot;max_value&quot;,&quot;pop_front&quot;,&quot;max_value&quot;]
[[],[1],[2],[],[],[]]
<strong>输出:&nbsp;</strong>[null,null,null,2,1,2]
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>
[&quot;MaxQueue&quot;,&quot;pop_front&quot;,&quot;max_value&quot;]
[[],[],[]]
<strong>输出:&nbsp;</strong>[null,-1,-1]
</pre>
<p>&nbsp;</p>
<p><strong>限制:</strong></p>
<ul>
<li><code>1 &lt;= push_back,pop_front,max_value的总操作数&nbsp;&lt;= 10000</code></li>
<li><code>1 &lt;= value &lt;= 10^5</code></li>
</ul>