-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path25.java
85 lines (64 loc) · 2.03 KB
/
25.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//{ Driver Code Starts
//Initial Template for Java
//Initial Template for Java
import java.io.*;
import java.util.*;
// } Driver Code Ends
//User function Template for Java
class Solution
{
void shuffleArray(long arr[], int n)
{
// Your code goes here
int j = n/2 , count = 0;
long ls[] = new long[n];
for(int i = 0 ; i < n/2 ; i++,j++)
{
ls[count++] = arr[i];
ls[count++] = arr[j];
}
for(int i = 0 ; i < n ; i++)
{
arr[i] = ls[i];
}
}
}
//{ Driver Code Starts.
// Driver class
class Array {
// Driver code
public static void main(String[] args) throws IOException {
// Taking input using buffered reader
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int testcases = Integer.parseInt(br.readLine());
// looping through all testcases
while (testcases-- > 0) {
int n = Integer.parseInt(br.readLine());
// String line = br.readLine();
// String[] q = line.trim().split("\\s+");
// int n =Integer.parseInt(q[0]);
// int k =Integer.parseInt(q[1]);
//int y =Integer.parseInt(a2[2]);
String line1 = br.readLine();
String[] a1 = line1.trim().split("\\s+");
long a[] = new long[n];
for (int i = 0; i < n; i++) {
a[i] = Long.parseLong(a1[i]);
}
// String line2 = br.readLine();
// String[] a2 = line2.trim().split("\\s+");
// long b[] = new long[n];
// for (int i = 0; i < m; i++) {
// b[i] = Long.parseLong(a2[i]);
// }
Solution ob = new Solution();
//ArrayList<Long> ans=
ob.shuffleArray(a,n);
// System.out.println(ob.shuffleArray(a,n));
for (int i = 0; i < n; i++)
System.out.print(a[i]+" ");
System.out.println();
}
}
}
// } Driver Code Ends