Amazon interview question

2 programs in Java/C++/JavaScript