Amazon interview question

String manipulation and binary search tree