IBM interview question

2 Leetcode medium questions in an hour