You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/com/fishercoder/solutions/_225.java
+27-20Lines changed: 27 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,16 @@
2
2
3
3
importjava.util.LinkedList;
4
4
importjava.util.Queue;
5
-
/**Implement the following operations of a stack using queues.
5
+
/**
6
+
* 225. Implement Stack using Queues
7
+
*
8
+
* Implement the following operations of a stack using queues.
6
9
7
10
push(x) -- Push element x onto stack.
8
11
pop() -- Removes the element on top of the stack.
9
12
top() -- Get the top element.
10
13
empty() -- Return whether the stack is empty.
14
+
11
15
Notes:
12
16
You must use only standard operations of a queue -- which means only push to back, peek/pop from front, size, and is empty operations are valid.
13
17
Depending on your language, queue may not be supported natively. You may simulate a queue by using a list or deque (double-ended queue), as long as you use only standard operations of a queue.
@@ -16,31 +20,34 @@ You may assume that all operations are valid (for example, no pop or top operati
16
20
The class name of the Java function had been updated to MyStack instead of Stack.*/
0 commit comments