McD Tech Labs Interview Question

2 LC medium complexity problem