X interview question

array number manipulation and returning after simple computation