EndoVantage Interview Question

Optimize code to speed it up