Microsoft interview question

It was coding questions from leetcode.