Amazon interview question

Asked 2 Questions based out of string and tree