New update is available. Click here to update.

Posted: 20 Mar, 2021

Difficulty: Moderate

```
Consider ARR1 = [1, 2] and ARR2 = [3, 4, 5, 6], then their Zigzag traversal will be represented by the list/array [1, 3, 2, 4, 5, 6].
We traverse in order ARR1[0], ARR2[0], ARR1[1], ARR2[1], ARR2[2], ARR2[3]. Note, ARR1 is completely traversed at the 3rd position, and after which we simply iterate over ‘ARR2’.
```

```
The first line of input contains an integer ‘T’ denoting the number of test cases. then ‘T’ test cases follow.
The first line of each test case consists of two single space-separated integers ‘N’ and ‘M’ representing the number of integers in ‘ARR1’ and ‘ARR2’ respectively.
The second line of each test case consists of ‘N’ single space-separated integers representing array ‘ARR1’
The third line of each test case consists of ‘M’ single space-separated integers representing array ‘ARR2’
```

```
For each test case, return an array of size ‘N’ + ‘M’ that contains integers representing Zigzag traversal of ‘ARR1’ and ‘ARR2’.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 50
0 <= N <= 10^4
0 <= M <= 10^4
0 <= ARR1[i] <= 10^9
0 <= ARR2[i] <= 10^9
N + M > 0
Time limit: 1 sec
```

SIMILAR PROBLEMS

Best time to buy and sell stock II

Posted: 5 Sep, 2022

Difficulty: Moderate

Ninja And The Class Room

Posted: 19 Sep, 2022

Difficulty: Easy

Array Rotation

Posted: 21 Oct, 2022

Difficulty: Easy

Find The Single Element

Posted: 30 Oct, 2022

Difficulty: Easy

Three Sum

Posted: 24 Nov, 2022

Difficulty: Moderate

Categories:

Popular Courses: