forum

Home / DeveloperSection / Forums / How Implement a Queue using two Stacks

How Implement a Queue using two Stacks

Erick Wilsom19921-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)


Updated on 30-May-2023
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

Can you answer this question?


Answer

2 Answers

Liked By