Amazon Interview Question

Ques 1)based on unordered_map Ques 2)based on tree