Microsoft interview question

Easy to meduim algorithm questions.