Honeywell interview question

Hacker rank 2 coding question.