Google Interview Question

Two leetcode medium questions, each roughly 40 mins