IBM Interview Question

2 Leetcode medium questions in an hour