/*
* @lc app=leetcode id=932 lang=cpp
*
* [932] Beautiful Array
*/
// @lc code=start
class Solution {
public:
vector<int> beautifulArray(int n) {
vector<int> ans = {1};
while(ans.size() < n) {
vector<int> tmp;
for(int i=0;i<ans.size();i++) if( ans[i] * 2 - 1 <= n) tmp.push_back(ans[i] * 2 - 1);
for(int i=0;i<ans.size();i++) if( ans[i] * 2 <= n) tmp.push_back(ans[i] * 2);
ans = tmp;
}
return ans;
}
};
// @lc code=end