Microsoft Interview Question

Typical array manipulation from leetcode