From e4c775636f2026f1b9eb552dc387c7d63c732eb0 Mon Sep 17 00:00:00 2001 From: Stackingrule <38368554+Stackingrule@users.noreply.github.com> Date: Tue, 15 Dec 2020 19:45:13 +0800 Subject: [PATCH] feat: add python and java solutions to leetcode problem: No.0089 --- solution/0000-0099/0089.Gray Code/Solution.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 solution/0000-0099/0089.Gray Code/Solution.cpp 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