Pergunta de entrevista da empresa Amazon

Leetcode medium question about array manipulation