Socotra Interview Question

Basic array questions and optimize time complexity.