Amazon Interview Question

Two coding questions, one easy, second medium