Pergunta de entrevista da empresa Element5

Array exchanging and indexing puzzle on reasoning