BNP Paribas interview question

explain hacker rank assignment solution