Wells Fargo Interview Question

Try to edit the given code for better performance