Amazon Interview Question

Mostly coding question of medium difficulty