IBM Interview Question

2 Moderate level DSA Question.