Pregunta de entrevista de Audible

Defining a function to solve an array related questions.