Microsoft interview question

1 coding question which was pretty straight forward