Google interview question

Leetcode, BQ, the lc problem is not so hard