IBM Interview Question

Medium level DSA question asked