Google interview question

2 Typical Leetcode Medium Problems