本文最后更新于 2025-03-30T12:48:25+08:00
                  
                  
                
              
            
            
              
                
                题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
   | 对于某些固定的 N,如果数组 A 是整数 1, 2, ..., N 组成的排列,使得:
  对于每个 i < j,都不存在 k 满足 i < k < j 使得 A[k] * 2 = A[i] + A[j]。
  那么数组 A 是漂亮数组。
   
  给定 N,返回任意漂亮数组 A(保证存在一个)。
   
  示例 1:
  输入:4 输出:[2,1,4,3] 示例 2:
  输入:5 输出:[3,1,2,5,4]  
  提示:
  1 <= N <= 1000
 
  | 
 
题目思路
1 2 3 4 5 6 7 8 9 10 11 12
   | class Solution { public:     vector<int> beautifulArray(int n) {         if(n == 1) return {1};         auto l = beautifulArray((n + 1) / 2);         auto r = beautifulArray(n / 2);         vector<int> ans;         for(auto x : l) ans.push_back(2 * x - 1);         for(auto x : r) ans.push_back(2 * x);         return ans;     } };
 
  | 
 
复杂度
                
               
            
            
            
              
              
  
  
    
      Day 70 932. 漂亮数组
      https://chaggle.github.io/2021/11/17/Leetcode/91-day/day-70/