Skip to content

Commit

Permalink
Alternate sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Varalakshmi2354 committed Oct 31, 2024
1 parent 5217b02 commit 653f963
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions october_2024/GFG_POTD_31_OCT_2024.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 653f963

Please sign in to comment.