Microsoft interview question

It was some random leetcode style question.