Microsoft interview question

Simple algorithm questions