Amazon interview question

Based or greedy tree and HashMap