eccenca interview question

Explain the solution for the coding challenge