BNP Paribas Interview Question

explain hacker rank assignment solution