Nielsen interview question

2 Leetcode medium questions were asked.