Users Pricing

forum

home / developersection / forums / how implement a queue using two stacks

How Implement a Queue using two Stacks

Erick Wilsom 603 21 Oct 2022

Problem

Suppose we have two stacks and no other temporary variable. Is to possible to "construct" a queue data structure using only the two stacks?

Complexity Analysis

Time Complexity must be -> O(1)

Space Complexity must be -> O(1)


Erick Wilsom

student

Writing is my profession! I have written hundreds of article for many organizations and looking forward to work with growing organization. I am compatible to produce content in many categories including International politics, Healthcare, Education, Lifestyle, etc.. I understand the value of your time that you have invested to read my bio. #thanks


2 Answers