Google interview question

Question based on array and vectors and then optimization.