Amazon interview question

Algorithms for specific problems given