Pregunta de entrevista de Wipro

Solving a Array problem and get the result