Amazon interview question

some from here, some from distributed computing