Tap here to switch tabs
Problem
Submissions

Problem: Beautiful Array

med
30 min
Try to solve the Beautiful Array problem.

Statement

An array nums of length n is considered beautiful if it is a permutation of the integers from 11 to n, and for every pair of indices i and j with 0≤0 \leq i << j << n, there does not exist any index k with i << k << j such that:

2imes2 imes nums[k] == nums[i] ++ nums[j]

Given an integer n, return any beautiful array nums of length n. It is guaranteed that at least one valid answer exists for the given n.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Beautiful Array

med
30 min
Try to solve the Beautiful Array problem.

Statement

An array nums of length n is considered beautiful if it is a permutation of the integers from 11 to n, and for every pair of indices i and j with 0≤0 \leq i << j << n, there does not exist any index k with i << k << j such that:

2imes2 imes nums[k] == nums[i] ++ nums[j]

Given an integer n, return any beautiful array nums of length n. It is guaranteed that at least one valid answer exists for the given n.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000