Vymo Interview Question

Leet code question on string and tree