• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
October 26, 2024 |300 Views

PROBLEM OF THE DAY : 25/10/2024 | Alternative Sorting

  Share  1 Like
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Ayush Tripathi We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

Given an array arr of distinct integers. Rearrange the array in such a way that the first element is the largest and the second element is the smallest, the third element is the second largest and the fourth element is the second smallest, and so on.

Examples:

Input: arr[] = [7, 1, 2, 3, 4, 5, 6] Output: [7, 1, 6, 2, 5, 3, 4] Explanation: The first element is first maximum and second element is first minimum and so on.
 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/alternative-sorting1311/1