Microsoft Interview Question

It was some random leetcode style question.