C ++ implementation of the approach
#include <bits/stdc++.h> NEW_LINE using namespace std ; int * solve ( int arr [ ] , int n ) { static int b [ 4 ] ; int p = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { b [ p ] = arr [ i -- ] ; if ( i >= 0 ) b [ n - 1 - p ] = arr [ i ] ; p ++ ; } return b ; }