# Middle-题目22：89. Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit.

Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.

For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:

00 - 0
01 - 1
11 - 3
10 – 2

，其中Gi表示格雷码的第i位，Bi表示二进制数的第i位。（因此生成格雷码的电路是异或门。）

public class Solution {
public List<Integer> grayCode(int n) {
List<Integer> gray = new ArrayList<Integer>();
for(int i = 0 ; i < 1<<n ; i++) {
int temp = i>>1;
}
return gray;
}
}

1ms,beats 58.59%,众数2ms,40.77%
cmershen的碎碎念：

#### LeetCode --- 89. Gray Code

2015-04-07 21:55:12

#### 【Leetcode】：89. Gray Code 问题 in JAVA

2016-05-10 14:04:39

#### LeetCode89:Gray Code

2015-07-07 15:59:59

#### [leetcode-89]Gray Code(c++)

2015-08-09 21:49:28

#### LeetCode(89)GrayCode

2014-02-14 08:07:30

#### [LintCode] 格雷编码 Gray Code

2016-04-14 21:30:05

#### [leetcode]89. Gray Code

2016-05-17 16:48:00

#### 89. Gray Code**

2017-01-14 00:17:59

#### LeetCode *** 89. Gray Code

2016-04-13 10:08:22

#### LeetCode - 89. Gray Code

2016-07-17 21:01:04