Netstudio interview question

Hacker rank easy algorithm problem