n = 0 mean the length is 0, so the program should return [].
Go fix the test case please.
I think it should return [] and not [0].
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.