Skip to content

Commit b7430dd

Browse files
committed
feat: add Solution.cpp for 0089.Gray Code
1 parent e13374b commit b7430dd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public:
3+
vector<int> grayCode(int n) {
4+
vector<int> res;
5+
for (int i = 0; i < (1 << n); ++i) {
6+
res.push_back((i >> 1) ^ i);
7+
}
8+
return res;
9+
}
10+
};

0 commit comments

Comments
 (0)