Array into Zigzag Fashion | Convert the given array into zigzag pattern

Array into Zigzag Fashion | Convert the given array into zigzag pattern

Printing an array into Zigzag fashion is discussed here. Suppose you were given an array of integers, and you are told to sort the integers in a zig-zag pattern. In general, in a zig-zag pattern, the first integer is less than the second integer, which is greater than the third integer, which is less than the fourth integer, and so on. Hence, the converted array should be in the form of e1 < e2 > e3 < e4 > e5 < e6.




Array into Zigzag Fashion | Convert the given array into zigzag pattern | FACE Prep


Test cases:


Input 1:

7

4 3 7 8 6 2 1


Output 1:

3 7 4 8 2 6 1


Input 2:

4

1 4 3 2


Output 2:

1 4 2 3




Array into zigzag pattern


Asked in Directin


@@coding::1@@


Recommended Programs








Array into Zigzag Fashion Convert the given array into zigzag pattern


c