Microsoft interview question

find and write code with given problem