Amazon Interview Question

two simple technique problems