Randstad US interview question

1. Explain the algorithm that I coded.