Microsoft Interview Question

Leetcode 636 as it is was asked