Amazon interview question

Hacker rank coding question with detailed problem statements