Microsoft Interview Question

LeetCode-style problems in both cases.