Optimal Blue interview question

What is a way to optimize your solution?