EPAM Systems interview question

To solve the problem which was a logical problem