Compass interview question

Coding question and follow up on that