Gyanthakur / GFG_POTD

Add GfG potd fcfs
26 stars 52 forks source link

POTD_25_OCT_2024_Alternate sorting #229

Closed Varalakshmi2354 closed 3 weeks ago

Varalakshmi2354 commented 3 weeks ago

Description

Given an array arr of distinct integers, rearrange the array such that the first element is the largest, the second element is the smallest, the third element is the second largest, and so on.

Fixes: #228

Use [x] to represent a checked (ticked) box.✅ Use [ ] to represent an unchecked box.❌

Type of Change

Checklist

Additional Notes

Complexity: A straightforward approach to this problem involves sorting the array and then rearranging the elements, resulting in a time complexity of O(nlogn).Edge Cases: Ensure the solution handles arrays with fewer than two elements appropriately.