Google Interview Question

Leetcode array question with a some minor changes