EPAM Systems Interview Question

Can you evaluate the algorithm's complexity?