Copia Global interview question

Coding algorith challenge in python