IBM interview question

Two coding questions, one medium, one hard