Allstate Interview Question

Can you walk me step-by-step through the algorithm you used to solve this problem?