Amazon Interview Question

Hash map and some optimizations