n = 0 mean the length is 0, so the program should return .
Go fix the test case please.
It should not be , but [special empty-string symbol]. From wikipedia: "The one-bit Gray code is G1 = (0, 1). This can be thought of as built recursively as above from a zero-bit Gray code G0 = ( Λ ) consisting of a single entry of zero length."
I think it should return  and not .
The question clearly says: "Given a non-negative integer n representing the total number of bits in the code,".
n=0 implies total number of bits in code is 0. So no bits in gray code. How can we expect a 0 in output, when one bit is required to represent 0 in gray code.
Question doesn't say anything about considering 2^0, or any length, as is pointed out by few guys in comments. It didn't even ask us to refer to its definition from Wikipedia.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.