Pergunta de entrevista da empresa IBM

A coding question based on arrays.