(int arr[], int n)
| 4 | // n: size of array |
| 5 | //Function to rearrange the array elements alternately. |
| 6 | public static void rearrange(int arr[], int n){ |
| 7 | |
| 8 | // Your code here |
| 9 | int j=0,k=n-1; |
| 10 | int key=arr[n-1]+1; |
| 11 | for(int i=0;i<n;i++) |
| 12 | { |
| 13 | // even should be max |
| 14 | if(i%2==0) |
| 15 | { |
| 16 | arr[i]=((arr[k]%key)*key)+arr[i]; |
| 17 | k--; |
| 18 | } |
| 19 | // odd should be min |
| 20 | else |
| 21 | { |
| 22 | arr[i] = ((arr[j]%key)*key)+arr[i]; |
| 23 | j++; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | for(int i=0;i<n;i++) |
| 28 | { |
| 29 | arr[i]/=key; |
| 30 | } |
| 31 | |
| 32 | } |
| 33 | |
| 34 | } |
nothing calls this directly
no outgoing calls
no test coverage detected