Moody's Interview Question

Two coding questions