Showing:
Handle Score
@Ibrahim Nash 5725
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Shuffle integers
Basic Accuracy: 9.85% Submissions: 366 Points: 1

Given an array arr[] of N elements in the following format {a1, a2, a3, a4, ….., an/2, b1, b2, b3, b4, …., bn/2}, the task is shuffle the array to {a1, b1, a2, b2, a3, b3, ……, an/2, bn/2} without using extra space.

Example 1:

Input: N = 4, arr[] = {1, 2, 9, 15}
Output:  1 9 2 15
Explanation: a1=1 , a2=2 , b1=9 , b2=9
So the final array will be :
a1, b1, a2, b2 = { 1, 9, 2, 15 }

Example 2:
Input: N = 6
arr[] = {1, 2, 3, 4, 5, 6}
Output: 1 4 2 5 3 6

This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function shuffleArray() that takes array arr[], and an integer N as parameters and modifies the given array according to the above-given pattern.

Expected Time Complexity: O(NlogN).
Expected Auxiliary Space: O(1).

Constraints:
1 ≤ N ≤ 105