关闭

89. Gray Code

220人阅读 评论(0) 收藏 举报
分类:
class Solution {
public:
    vector<int> grayCode(int n) {
        vector<int> result;
        result.push_back(0);
        for(int i=0;i<n;i++)
        {
            for(int j=result.size()-1;j>=0;j--)
            {
                result.push_back(result[j]|1<<i);
            }
        }
        return result;
    }
};
1
0
查看评论

LeetCode --- 89. Gray Code

题目链接:Gray Code The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n represent...
  • makuiyu
  • makuiyu
  • 2015-04-07 21:55
  • 2004

LeetCode89:Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total numb...
  • u012501459
  • u012501459
  • 2015-07-07 15:59
  • 1030

LeetCode(89)GrayCode

题目如下: The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the tot...
  • feliciafay
  • feliciafay
  • 2014-02-14 08:07
  • 2157

89. Gray Code M

LeetCode 89 GrayCode M
  • sinat_29621543
  • sinat_29621543
  • 2016-09-06 20:40
  • 128

[leetcode]89. Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing ...
  • u010112493
  • u010112493
  • 2016-05-17 16:48
  • 155

[leetcode] 89. Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing ...
  • TstsUgeg
  • TstsUgeg
  • 2016-04-06 11:50
  • 244

89. Gray Code(Python3)

89. Gray Code(Python3) 题目 The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer...
  • grape875499765
  • grape875499765
  • 2018-01-30 00:02
  • 35

LeetCode *** 89. Gray Code

题目: The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the t...
  • treeshy
  • treeshy
  • 2016-04-13 10:08
  • 85

leetcode 89. Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing ...
  • u014568921
  • u014568921
  • 2016-04-17 20:59
  • 372

【leetcode】89. Gray Code

一、题目描述 The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n r...
  • xiaoquantouer
  • xiaoquantouer
  • 2016-09-04 23:08
  • 168
    个人资料
    • 访问:109128次
    • 积分:4835
    • 等级:
    • 排名:第7033名
    • 原创:374篇
    • 转载:7篇
    • 译文:0篇
    • 评论:6条
    最新评论