IBM Interview Question

2 Medium-difficulty leetcode questions to be done in an hour