Amazon Interview Question

Leetcode easy, it was array related