public List<Integer> grayCode(int n) {
List<Integer> res = new ArrayList<>();
getGrayCode(n, num, res);
public void getGrayCode(int n, int[] num, List<Integer> res) {
// For each bit of the num, we either leave it alone or invert the current bit
// Leave the current bit alone
getGrayCode(n - 1, num, res);
// Invert the current bit
getGrayCode(n - 1, num, res);