Convert array into Zig-Zag fashion
Given an array Arr (distinct elements) of size N. Rearrange the elements of array in zig-zag fashion. The converted array should be in form a < b > c < d > e < f. The relative order of elements is same in the output i.e you have to iterate on the original array only.
- Time : O(n)
- Space : O(1)
1 | class Solution{ |