Pergunta de entrevista da empresa Allegion

Write a program to until it reached the max and min Range of array, by adding the index and corresponding value and break if it follows the same path