Google Interview Question

An Array leetcode medium question