Veeva Systems interview question

Easy to medium algorithm question