Microsoft interview question

2 mid-level coding problems, similar to Leetcode.