Google Interview Question

leetcode hard was unexpected and very difficult