Amazon Interview Question

String manipulation and binary search tree