HEMA interview question

How do you improve the solution?