Matic interview question

Implement C++ challenge, cannot share here.