diff --git a/october_2024/GFG_POTD_31_OCT_2024.py b/october_2024/GFG_POTD_31_OCT_2024.py new file mode 100644 index 0000000..72502b1 --- /dev/null +++ b/october_2024/GFG_POTD_31_OCT_2024.py @@ -0,0 +1,16 @@ +class Solution: + def alternateSort(self,arr): + arr.sort() + result = [] + i, j = 0, len(arr) - 1 + + while i <= j: + if i != j: + result.append(arr[j]) + result.append(arr[i]) + else: + result.append(arr[j]) + i += 1 + j -= 1 + + return result \ No newline at end of file