Microsoft Interview Question

Two problems with medium difficulty to solve