//看不懂啊看不懂,开摆!
public List<Integer> grayCode(int n) {
List<Integer> ret = new ArrayList<Integer>();
ret.add(0);
for (int i = 1; i <= n; i++) {
int m = ret.size();
for (int j = m - 1; j >= 0; j--) {
ret.add(ret.get(j) | (1 << (i - 1)));
}
}
return ret;
}
2022.1.8-----leetcode.89
最新推荐文章于 2024-11-05 21:58:11 发布