Repository navigation
v1.0.1
What's Changed
Full Changelog: v1.0.0...v1.0.1
New Supported Feature
Support data design type question debugging.
Example
Question
Implement-Stack-Using-Queues
Code
//SimpleTest.java
public class SimpleTest extends LeetcodeJavaDebugEnhancer {
class MyStack {
Queue<Integer> queue1;
Queue<Integer> queue2;
/** Initialize your data structure here. */
public MyStack() {
queue1 = new LinkedList<Integer>();
queue2 = new LinkedList<Integer>();
}
/** Push element x onto stack. */
public void push(int x) {
queue2.offer(x);
while (!queue1.isEmpty()) {
queue2.offer(queue1.poll());
}
Queue<Integer> temp = queue1;
queue1 = queue2;
queue2 = temp;
}
/** Removes the element on top of the stack and returns that element. */
public int pop() {
return queue1.poll();
}
/** Get the top element. */
public int top() {
return queue1.peek();
}
/** Returns whether the stack is empty. */
public boolean empty() {
return queue1.isEmpty();
}
}
}Input
["MyStack","push","push","top","pop","empty"] [[],[1],[2],[],[],[]]
Output
[null,null,null,2,2,false]