# More example needed

• For there is no special judge here, can you provide more complex samples to help us to get an idea of the 'pattern' by which the answer is fabricated?
For example, examples when n = 3 or n = 4 is sufficient.

• Here are the examples. I write it in this way so hopefully you could also figure out a way to solve this problem by studying the patterns.

n = 3

0 0 0

0 0 1

0 1 1

0 1 0

------

1 1 0

1 1 1

1 0 1

1 0 0

n = 4

0 0 0 0

0 0 0 1

0 0 1 1

0 0 1 0

0 1 1 0

0 1 1 1

0 1 0 1

0 1 0 0

---------

1 1 0 0

1 1 0 1

1 1 1 1

1 1 1 0

1 0 1 0

1 0 1 1

1 0 0 1

1 0 0 0

• in what order should the binary stream be outputted? I can generate the stream, not a problem, but how does OJ generate its own order? e.g. in my case I have it sorted, and such solution fails the test cases.

n = 4
{
{0 0 0 0},
{0 0 0 1},
{0 0 1 0},
{0 0 1 1},
{0 1 0 0},
{0 1 0 1},
{0 1 1 0},
{0 1 1 1}
}
Could anyone please comment on the order.

Thanks.

• Notice that your many of the elements in your answer differ in more than 1 bit, e.g. 2nd and 3rd element in your answer differ in 2 bits, namely {0 0 0 1}, {0 0 1 0}. The gray code is not asking you to simply output all possible sequences, your sequence should satisfy this condition:

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

So look at above example again and you will notice that those example sequences satisfy the requirement while yours doesn't.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.