mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 03:11:42 +08:00
add leetcode problem-cn part2
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<p>Implement a MyQueue class which implements a queue using two stacks.</p>
|
||||
|
||||
|
||||
<p><strong>Example: </strong></p>
|
||||
|
||||
<pre>
|
||||
MyQueue queue = new MyQueue();
|
||||
|
||||
queue.push(1);
|
||||
queue.push(2);
|
||||
queue.peek(); // return 1
|
||||
queue.pop(); // return 1
|
||||
queue.empty(); // return false</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><b>Notes:</b></p>
|
||||
|
||||
<ul>
|
||||
<li>You must use <i>only</i> standard operations of a stack -- which means only <code>push to top</code>, <code>peek/pop from top</code>, <code>size</code>, and <code>is empty</code> operations are valid.</li>
|
||||
<li>Depending on your language, stack may not be supported natively. You may simulate a stack by using a list or deque (double-ended queue), as long as you use only standard operations of a stack.</li>
|
||||
<li>You may assume that all operations are valid (for example, no pop or peek operations will be called on an empty queue).</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
Reference in New Issue
Block a user