Yahoo interview question

Two coding questions not easy