Implement a queue data structure using only two given stacks.
Let the two given stacks be named as \( stack1 \) and \( stack2 \). The algorithm to implement a \( queue \) by using two \( stacks \) works as :
Time complexity for \( enqueue \) operation is \( O(1) \) whereas for \( dequeue \) operation \( O(n) \). \( \therefore \) Overall time complexity is \( O(n) \). public class implementQueueUsingStacks { |