Company: Barclays (2027 Compliance Analyst Summer Internship Programme India)_22july
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. In other words, sort the list in non-decreasing order and then take the elements at positions 0, 2, 4, 6, and so on. You are given a list of unsorted elements. Write a program to find the alternate sort of the given list. Input The first line of the input contains an integer size , representing the size of the given list (N). The second line contains N space-separated integers arr[0], arr[1], ..., arr[N-1] , representing the elements of the input list. Output Print space-separated integers representing the alternately sorted elements of the given list. Constraints 0 < size <= 10^6 -10^6 <= arr[i] <= 10^6 0 <= i < size Example 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 alternate elements of the sorted list, starting at the first position, are [1, 3,