← All problemsSign in

2164. Sort Even and Odd Indices Independently

LeetCodeArraySortingOpen on judge ↗

You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules: - Sort the values at odd indices of nums in non-increasing order. - For example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order. - Sort the values at even indices of nums in non-decreasing order.

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start