Apify interview question

How would you improve time complexity of a given code?