diff --git a/solution/0000-0099/0089.Gray Code/Solution.cpp b/solution/0000-0099/0089.Gray Code/Solution.cpp new file mode 100644 index 0000000000000..07b6bc772dcb6 --- /dev/null +++ b/solution/0000-0099/0089.Gray Code/Solution.cpp @@ -0,0 +1,13 @@ +class Solution +{ +public: + vector grayCode(int n) + { + vector res; + for (int i = 0; i < pow(2, n); ++i) + { + res.push_back((i >> 1) ^ i); + } + return res; + } +}; \ No newline at end of file