Publicis Groupe interview question

Explain your solution of the coding question