← All problemsSign in

932. Beautiful Array

LeetCodeArrayMathDivide and ConquerOpen on judge ↗

An array nums of length n is beautiful if: - nums is a permutation of the integers in the range [1, n]. - For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i] + nums[j]. Given the integer n, return any beautiful array nums of length n. There will be at least one valid answer for the given n. Example 1: Input: n = 4 Output: [2,1,4,3] Example 2: Input: n

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