Amazon Interview Question

Asked 2 Questions based out of string and tree