Amazon Interview Question

Both coding questions were easy