LeetCode--Gray Code
2014-08-12 00:01
323 查看
格雷码的定义
第二次写的,参考别人。代码写的很简洁
第二次写的,参考别人。代码写的很简洁
class Solution { public: vector<int> grayCode(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<int> res; res.push_back(0); int highbit = 0; while(n--) { highbit = res.size(); for(int i= res.size()-1; i >= 0; i--) res.push_back(highbit|res[i]); } return res; } };
相关文章推荐
- leetcode题解-89. Gray Code
- [leetcode 89] Gray Code
- LeetCode 89. Gray Code(格雷码)
- leetcode 89:Gray Code
- LeetCode Gray Code
- LeetCode——Gray Code
- [LeetCode] Gray Code 解题报告
- LeetCode 89: Gray Code 格雷码
- 【Leetcode】Gray Code (Pascal)
- LeetCode 89 Gray Code
- leetcode89~Gray Code
- LeetCode | 89. Gray Code
- [Leetcode]Gray Code
- leetcode 日经贴,Cpp code -Gray Code
- Leetcode 89 Gray Code
- [LeetCode] 89. Gray Code 格雷码
- Leetcode88: Gray Code
- Java for LeetCode 089 Gray Code
- [leetcode] 89. Gray Code 解题报告
- leetcode 89:Gray Code