@@ -0,0 +1,973 @@
+/**%0A * Problem Link: https://leetcode.com/problems/gray-code/%0A * %0A * Iterate every code, generate next code based on current(latest) code.%0A */%0Apublic class Solution %7B%0A    private HashSet%3CInteger%3E set;%0A    private List%3CInteger%3E list;%0A    %0A    public List%3CInteger%3E grayCode(int n) %7B%0A        set = new HashSet%3CInteger%3E();%0A        list = new ArrayList%3CInteger%3E();%0A        set.add(0);%0A        list.add(0);%0A        next(0, n);%0A        return list;%0A    %7D%0A    %0A    private void next(int last, int n) %7B%0A        for(int i=0; i%3Cn; i++) %7B%0A            int bit = 1 & (last %3E%3E i);%0A            int ret = last;%0A            if(bit == 0) %7B%0A                ret += (1 %3C%3C i);%0A            %7D%0A            else %7B%0A                ret -= (1 %3C%3C i);%0A            %7D%0A            //System.out.println(ret);%0A            Integer r = Integer.valueOf(ret);%0A            if(!set.contains(r)) %7B%0A                list.add(r);%0A                set.add(r);%0A                next(ret, n);%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Create Gray_Code.java