Given an array of integers nums, rearrange the elements such that for every index i where i nums.length nums[i] is not equal to the average of its immediate neighbors, nums[i - 1] and nums[i + 1].
Return any valid permutation of nums that satisfies this condition.
Note: If multiple valid arrangements exist, return any of them.
Constraints:
nums.length
nums[i]
Given an array of integers nums, rearrange the elements such that for every index i where i nums.length nums[i] is not equal to the average of its immediate neighbors, nums[i - 1] and nums[i + 1].
Return any valid permutation of nums that satisfies this condition.
Note: If multiple valid arrangements exist, return any of them.
Constraints:
nums.length
nums[i]