Amazon Interview Question

queue and stack question, easy