State Farm interview question

A problem that i had to solve