Microsoft interview question

Basic array algorithm