Expedia Group Interview Question

The question around the efficiency algorithm I have posted above