Imperva interview question

Coding assignment on hacker rank.