Microsoft interview question

Two coding questions they asked