Pregunta de entrevista de Amazon

Array related problem. easily found in previous question papers.