Glassdoor interview question

How would you code and design a solution for this problem?