Company: Natwest_7aug
Difficulty: easy
An alternate sort of a list consists of the alternate elements (starting from the first position) of the given list after sorting it in ascending order. You are given a list of unsorted elements. Write a program to find the alternate sort of the given list. Input Format The first line of the input consists of an integer size , representing the size of the given list (N). The second line consists of N space-separated integers arr 0 , arr 1 , …, arr N-1 , representing the elements of the input list. Output Format Print space-separated integers representing the alternately sorted elements of the given list, i.e. the elements at indices 0, 2, 4, … of the sorted list. Constraints 0 < size ≤ 10 6 -10 6 ≤ arr i ≤ 10 6 0 ≤ i < size Example 1 Input 8 3 5 1 5 9 10 2 6 Output 1 3 5 9 Explanation: After sorting, the list is [1, 2, 3, 5, 5, 6, 9, 10] . The elements at indices 0, 2, 4 and 6 are [1, 3, 5, 9] . Example 2 Input 7 3 1 5 2 9 5 10 Output 1 3 5 10 Explanatio