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 00 - 0 01 - 1 11 - 3 10 - 2 Note: For example, For now, the judge is able to judge based on one instance of gray code sequence. Sorry about that. |
The question has been closed for the following reason "bulk close" by 1337c0d3r 25 Oct '13, 06:41
A recursive solution in java
|
link
This answer is marked "community wiki".
|
|
|
An alternative solution using bit operations
|
|