Microsoft interview question

2 Leetcode style questions (easy)