0932. Beautiful Array
https://leetcode.com/problems/beautiful-array
Description
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 indexk
withi < k < j
where2 * 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:
Example 2:
Constraints:
1 <= n <= 1000
ac
Last updated