Expedia Group interview question

The question around the efficiency algorithm I have posted above