Amazon interview question

Use a buffer to generate queries