Pregunta de entrevista de Google

Question based on array and vectors and then optimization.