1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 05:26:46 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>实现一个MyQueue类该类用两个栈来实现一个队列。</p><br><p><strong>示例:</strong><pre>MyQueue queue = new MyQueue();<br><br>queue.push(1);<br>queue.push(2);<br>queue.peek(); // 返回 1<br>queue.pop(); // 返回 1<br>queue.empty(); // 返回 false</pre></p><br><p><strong>说明:</strong><br><ul><li>你只能使用标准的栈操作 -- 也就是只有 <code>push to top</code>, <code>peek/pop from top</code>, <code>size</code> 和 <code>is empty</code> 操作是合法的。</li><li>你所使用的语言也许不支持栈。你可以使用 list 或者 deque双端队列来模拟一个栈只要是标准的栈操作即可。</li><li>假设所有操作都是有效的 (例如,一个空的队列不会调用 pop 或者 peek 操作)。</li></ul></p>",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 51,
"likes": 56,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"27.5K\", \"totalSubmission\": \"38.5K\", \"totalAcceptedRaw\": 27533, \"totalSubmissionRaw\": 38524, \"acRate\": \"71.5%\"}",
"stats": "{\"totalAccepted\": \"28.2K\", \"totalSubmission\": \"39.5K\", \"totalAcceptedRaw\": 28177, \"totalSubmissionRaw\": 39457, \"acRate\": \"71.4%\"}",
"hints": [
"队列和栈的主要区别是元素的顺序。队列删除最旧的项,栈删除最新的项。如果你只访问最新的项,那么如何从栈中删除最旧的项?",
"我们可以通过不断地删除最新的项将这些项插入临时栈中来删除栈中最老的项直到得到一个元素为止。然后在检索到最新项后将所有元素返回。与此有关的问题是每次在一行中做几个弹出操作pop将需要O(n)的时间。我们可以优化在一行中连续弹出这一场景吗?"