#232.Implement Queue using Stacks [LeetCode Grind 75 in Java]

[Problem Link] https://leetcode.com/problems/implement-queue-using-stacks/

class MyQueue {

    public Stack<Integer> st1;
    public Stack<Integer> st2;

    public MyQueue() {
        st1 = new Stack<>();
        st2 = new Stack<>();
    }

    public void push(int x) {
        st1.push(x);
    }

    public int pop() {
        peek();
        return st2.pop();
    }

    public int peek() {
        if(st2.isEmpty()) {
            while(!st1.isEmpty()) st2.push(st1.pop());
        }

        return st2.peek();
    }

    public boolean empty() {
        return st1.isEmpty() && st2.isEmpty();
    }
}