Amazon Interview Question

Different problems taken from hackerrank site