Vymo interview question

Leet code question on string and tree