原题地址:https://leetcode.com/problems/gray-code/

class Solution {
public:
vector<int> grayCode(int n) {
vector<int> coll;
if(n == || n == ) {
coll.push_back();
if(n)
coll.push_back();
return coll;
}
coll = (grayCode(n - ));
int i = coll.size() - ;
for(; i >= ; --i)
coll.push_back(pow(2.0, n - ) + coll[i]); return coll;
}
};

LeetCode题目:Gray Code的更多相关文章

  1. [leetcode.com]算法题目 - Gray Code

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

  2. [LeetCode] 89. Gray Code 格雷码

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

  3. leetcode[88] Gray Code

    题目:格雷码. 格雷码是从0开始且之后两个相邻码之间只有一个符号不相同,例如000,100,101,111三个相邻之间只有一个二进制不同. 现在给定一个数字n,然后给出格雷码所对应的数字.例如: Fo ...

  4. Java for LeetCode 089 Gray Code

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

  5. 【LeetCode】Gray Code

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

  6. 【leetcode】Gray Code (middle)

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

  7. 【题解】【排列组合】【回溯】【Leetcode】Gray Code

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

  8. leetCode 89.Gray Code (格雷码) 解题思路和方法

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

  9. Leetcode#89 Gray Code

    原题地址 二进制码 -> 格雷码:从最右边起,依次与左边相邻位异或,最左边一位不变.例如: 二进制: 1 0 0 1 1 1 0 |\|\|\|\|\|\| 格雷码: 1 1 0 1 0 0 1 ...

随机推荐

  1. 杭电oj2032、2040、2042、2054、2055

    2032  杨辉三角 #include <stdio.h> int main(){ ][],i,j,n; while(~scanf("%d",&n)){ ;i& ...

  2. 转 DNS原理及其解析过程【精彩剖析】

    DNS原理及其解析过程[精彩剖析] http://369369.blog.51cto.com/319630/812889/   DNS原理及其解析过程 精彩剖析         网络通讯大部分是基于T ...

  3. 10.OpenStack块存储服务

    添加块存储服务 安装和配置控制器节点 创建数据库 mysql -uroot -ptoyo123 CREATE DATABASE cinder; GRANT ALL PRIVILEGES ON cind ...

  4. 你不一定知道的、并没有什么卵用的一些python库

    1. delorean,用来处理时间的库 import datetime import pytz # 一般情况下,我们想表示时间的话 est = pytz.timezone("Asia/Sh ...

  5. BootStrap容器介绍

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  6. nginx安全日志分析脚本的编写

    https://blog.csdn.net/nextdoor6/article/details/51914966

  7. [BZOJ1018][SHOI2008]堵塞的交通traffic 线段树维护连通性

    1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec  Memory Limit: 162 MB Submit: 3795  Solved: 1253 [Sub ...

  8. 转 linux任务调度之crontab命令

    crontab命令常见于Unix和Linux的操作系统之中,用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于"crontab"文件中,以供之后读取和执行. 在 ...

  9. Mysql 通用二进制包安装

    通用二进制包安装 注意:这里有严格的平台问题: 使用时:centos5.5版本   (类似Windows下的绿色包) 下载(mirrors.sohu.com/mysql)   直接使用tar 解压到指 ...

  10. Java混乱的日志体系(logback)(转)

    作为一名 Java 程序员,日常开发工作中肯定会接触日志系统,但是众多的框架,包括 Log4j.Log4j2.Logback.Slf4j.Apache Common logging 等等,引用的 ma ...