Amazon Interview Question

Stack question leet code easy