I solved this problem using bits manipulation and got accepted. However I am just wondering, can we solve it like i mentioned below.

Gray codes would always be numbers starting from 0 to (2^n - 1).

```
public class Solution {
public List<Integer> grayCode(int n) {
List<Integer> listObj = new ArrayList<Integer>();
for(int i=0;i<Math.pow(2,n);i++){
listObj.add(i);
}
return listObj;
}
}
```

Thanks.