LinkedIn interview question

2 Medium level DS/Algo problems