Pregunta de entrevista de ServiceNow

Asked me to solve an array problem.