We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9009c2 commit 168ff46Copy full SHA for 168ff46
gray_code.py
@@ -0,0 +1,11 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+class Solution:
4
+ # @param {int} n a number
5
+ # @return {int[]} Gray code
6
+ def grayCode(self, n):
7
+ # Write your code here
8
+ ret = []
9
+ for i in xrange(1 << n):
10
+ ret.append((i >> 1) ^ i)
11
+ return ret
0 commit comments