Problem statement

https://binarysearch.com/problems/Large-to-Small-Sort/

Solution

Just do what is asked, using slices.

Complexity

It is O(n log n) for time and O(n) for space.

Code

class Solution:
    def solve(self, nums):
        n = len(nums)
        nums = sorted(nums)
        arr = [0] * n
        n1, n2 = len(arr[::2]), len(arr[1::2])
        arr[::2] = nums[::-1][:n1]
        arr[1::2] = nums[:n2]
        return arr