作者:jyd
链接:https://leetcode-cn.com/problems/gray-code/solution/gray-code-jing-xiang-fan-she-fa-by-jyd/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
每天也就靠看看题解混混日子了。
个人微改:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class GrayCode {
public static void main(String args[]) {
System.out.println("please enter the value :");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println(grayCode(n));
sc.close();
}
public static List
List
int head = 1;
for(int i=0;i
res.add(res.get(j)+head);
}
head <<= 1;
}
return res;
}
}



