Netstudio Interview Question

Hacker rank easy algorithm problem