Amazon Interview Question

All I answered had to be coded.