Google Interview Question

something close to leetcode 300