GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Implement two stacks with a single deque so that each operation takes a constant number of deque operations.

I 'm trying to make it in python, 
class stacka2_deque():
    def __init__(self):
        self.myDeque=[]
        self.stack1=[]
        self.stack2=[]

    def push_right(self, x):
        self.myDeque.append(x)

    def push_left(self, x):
        self.myDeque.insert(0,x)

    def pop_right(self):
        return self.stack1.append(self.myDeque.pop())

    def pop_left(self):
        return self.stack2.append(self.myDeque.pop(0))
asked Oct 31, 2015 by inahem

1 Answer

Care to explain more? What exactly you want to ask?
You can simply use a delimiter to separate the two stacks from one another and thus implement two stacks using a deque using both it's ends as the stack tops. 

answered Oct 31, 2015 by Swanky

this is all: 

Two stacks with a deque. Implement two stacks with a single deque so that each
operation takes a constant number of deque operations.

I don't understand what it wants too!!!!

...