Amazon interview question

Some online coding test on hackerrank