Goldman Sachs interview question

The first problem is Good Array. The difficult point is it is possible to exceed time limit. The second problem is leetcode 1010. We need to use a hash map.