Amazon interview question

queue and stack question, easy