ZET interview question

coding question on optimization of a list