Model N Interview Question

All the rounds they ask this question Creating a queue from stack