EPAM Systems interview question

Coding round based on DS and Algo.