X Interview Question

array number manipulation and returning after simple computation