Microsoft interview question

Leetcode easy coding problem