Naumen interview question

Algorithms complexity