Amazon Interview Question

Leetcode medium question about array manipulation