Amazon Interview Question
Software Engineer / DevelopersPop from stack 1 into stack 2 till pointer->next=null (i.e the last element to be popped from stack 1) this is the element to be deleted.
After that pop all the elements back from stack 2 to stack 1. This is in case there is another insertion before the next delete operation.
use 2 stack...call in stack 1 and stack 2
- Anonymous April 05, 2010insertion in queue is done by pushing on stack 1
extraction from queue in done by popping from stack 2
if stack 2 is empty then pop all from stack 1 and push to stack 2