Amazon Interview Question

Data structure question