2164. Sort Even and Odd Indices Independently

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2164

class Solution:
    def sortEvenOdd(self, nums: List[int]) -> List[int]:
        a = sorted(nums[::2])
        b = sorted(nums[1::2], reverse=True)
        nums[::2] = a
        nums[1::2] = b
        return nums