class Solution {

public:

vector<int> grayCode(int n) {

vector<int> result;

int size, inc;

if(n<0)

return result;

result.push_back(0);

if(n==0)

return result;

```
for(int i=0; i<n; i++){
size = result.size();
inc = 1 << i;
for(int j=size-1; j!=-1; j--)
result.push_back(result[j] + inc);
}
return result;
}
```

};