89. Gray Code

原创 2016年06月02日 11:07:42

格雷码

For example, given n = 2, return [0,1,3,2].

代码

public class Solution {
    public List<Integer> grayCode(int n) {
        List<Integer> result = new LinkedList<>();
        for (int i = 0; i < 1<<n; i++) result.add(i ^ i>>1);
        return result;
    }
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

LeetCode 89. Gray Code(格雷码)

原题网址:https://leetcode.com/problems/gray-code/ The gray code is a binary numeral system where two s...

递归算法+奇妙规律 89. Gray Code

参考分析见链接 http://blog.csdn.net/makuiyu/article/details/44926463 转载: 题目链接:Gray Code The gray code is...

LeetCode 89 Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit. Given ...

LeetCode #89 - Gray Code - Medium

ProblemThe gray code is a binary numeral system where two successive values differ in only one bit.G...

[leetcode] 【数组】 89. Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit. Give...

89. Gray Code [leetcode]

89. Gray Code The gray code is a binary numeral system where two successive values differ in only...

89. Gray Code \ 51. N-Queens \ 52. N-Queens II

Gray Code 题目描述 解题思路 N-Queens 题目描述 代码实现89. Gray Code题目描述The gray code is a binary numeral system wher...

LeetCode89/60 Gray Code/Permutation Sequence--迭代

一:Leetcode 89 Gray Code 题目:The gray code is a binary numeral system where two successive values...

LeetCode_89_Gray Code 格雷码

题目描述 The gray code is a binary numeral system where two successive values differ in only one bit. ...

LeetCode 89: Gray Code解题报告

LeetCode89: Gray Code题解报告 提交网址: https://leetcode.com/problems/gray-code/  89. Gray Code Tot...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)