Amazon interview question

Different problems taken from hackerrank site