F5 interview question

Solve the following coding question