Domanda di colloquio di Bloomberg

Question about tree implementation, and a dp problem