Adobe interview question

Medium DS and Algo problems