MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / beautifulArray

Method beautifulArray

932. Beautiful Array/Solution.cpp:15–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13class Solution {
14public:
15 vector<int> beautifulArray(int N) {
16 vector<int> res = {1};
17 while (res.size() < N) {
18 vector<int> tmp;
19 for (int i : res) if (i * 2 - 1 <= N) tmp.push_back(i * 2 - 1);
20 for (int i : res) if (i * 2 <= N) tmp.push_back(i * 2);
21 res = tmp;
22 }
23 return res;
24 }
25};
26
27int main() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected