Helmes interview question

Logical task