YipitData interview question

Explain how you approached the assignment