Pergunta de entrevista da empresa Google

Two questions, one about binary tree and the other about strings