Pergunta de entrevista da empresa Socotra

Basic array questions and optimize time complexity.