Consider a case where you have been given a queue and you need to convert it to stack. How will you do it?
Asked in the Technical Interview I stage. Follow-up: write a C program and explain it, then solve the same task using two queues.
For this version, the input is a list representing a queue from front to rear. Return a list representing the converted stack from top to bottom. The original queue order must therefore be reversed in the returned stack.
def queue_to_stack(queue):