题目:
842. Origami
Origami, each time the paper is folded from right to left, the dent is 0, the bump is 1. After the n number of folds, find the 01 sequence of the creases formed with the paper unrolling.

Example
Given n = 1, return “0”.

Explanation:
the 01 sequence of the creases is “0”.
Given n = 2, return “001”.

Explanation:
the 01 sequence of the creases is “001”.
Notice
1 <= n <= 20

我们可看出一些规律:
#1: 0
#2: 001
#3: 0010011
#4: 001001100011011

设第i次结果为s, 那么第i+1次结果为s + ‘0’ + s.reverse().flip()。
例如: 001001100011011 = 0010011 + ‘0’ + 0011011
其中0011011即0010011的0/1互换 并倒转。

class Solution {
public:/*** @param n: The folding times* @return: the 01 string*/string getString(int n) {string s = "0";for (int i = 2; i <= n; ++i) {string reverseS;int len = s.size();s.push_back('0');for (int j = 0; j < len; ++j) {s.push_back(1 ^ (s[len - 1 - j] - '0') + '0');}}return s;}
};

LintCode 842: Origami相关推荐

  1. LintCode 249. 统计前面比自己小的数的个数

    给定一个整数数组(下标由 0 到 n-1, n 表示数组的规模,取值范围由 0 到10000).对于数组中的每个 ai 元素,请计算 ai 前的数中比它小的元素的数量. 注意事项 We suggest ...

  2. LintCode: Max Tree

    题目 Given an integer array with no duplicates. A max tree building on this array is defined as follow ...

  3. 【LintCode: 3. 统计数字】算法题解析

    这是一道来自LintCode的算法题目,本文用C++来解答这道题,链接为: https://www.lintcode.com/problem/digit-counts/description 题目描述 ...

  4. LintCode 1.A+B的问题

    LintCode 1.A+B的问题 描述 给出两个整数 a 和 b , 求他们的和. 答案 public class Solution {/*** @param a: An integer* @par ...

  5. 关于爬楼梯的lintcode代码

    讲真的,这个我只会用递归去做,但是lintcode上面超时,所以只有在网上找了个动态规划的,虽然这个程序懂了,但是我觉得还是挺不容易的真正弄懂的话-- class Solution { public: ...

  6. lintcode: k Sum 解题报告

    K SUM My Submissions http://www.lintcode.com/en/problem/k-sum/ 题目来自九章算法 13% Accepted Given n distinc ...

  7. LintCode Longest Increasing Continuous Subsequence

    原题链接在这里:http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/ 题目: Give an in ...

  8. lintcode 滑动窗口的最大值(双端队列)

    题目链接:http://www.lintcode.com/zh-cn/problem/sliding-window-maximum/# 滑动窗口的最大值 给出一个可能包含重复的整数数组,和一个大小为  ...

  9. leetcode 293.Flip Game(lintcode 914) 、294.Flip Game II(lintcode 913)

    914. Flip Game https://www.cnblogs.com/grandyang/p/5224896.html 从前到后遍历,遇到连续两个'+',就将两个加号变成'-'组成新的字符串加 ...

  10. Origami – 用于 Quartz 的免费的交互设计框架

    Origami 是一个为 Quartz Composer 开发的免费的工具包--由Facebook设计团队创建,让交互设计原型更加简单,不需要编程. 如今,大多数设计师通过创建静态原型来表达要实现的应 ...

最新文章

  1. 一口气说出 5 种 IO 模型,蒙圈了!
  2. C# 正则表达式过滤危险HTML
  3. 学生用计算机说明方法,15.文中多处运用了作比较的说明方法.请任选一例.说说运用这种方法的作用. 例子: 作用:...
  4. 条件概率分布_条件概率
  5. oracle values函数,Oracle文本函数简介
  6. flutter 轮播图动态加载网络图片
  7. Google Maps JavaScript API V3 官方网站
  8. 老式Windows桌面的终结:Windows 11来了,DaaS还会远吗?
  9. ios程序中调用腾讯OpenAPI时遇到的问题
  10. 十六进制高低位转换,返回十进制数
  11. python点云可视化
  12. 寻路算法 --- A星寻路算法
  13. 关于用c语言演奏《天空之城》那些事
  14. html5 梵高 星,上海梵高星空艺术馆门票
  15. 蓝牙耳机品牌排行榜,连接稳定的四款蓝牙耳机分享
  16. 08_基于IP的伪装
  17. 易语言-王者天下页游自动回收辅助
  18. torch对于tensor的常规操作
  19. python 一些模块的应用
  20. SDSoC软硬件协同设计流程系列——1.基于SDSoC的软硬件协同设计流程简介

热门文章

  1. JetBrains系列产品学生认证申请免费使用教程
  2. eviews9.0详细安装步骤
  3. 数据库原理课程设计---停车场管理系统
  4. 序列号Serial Number管理
  5. 台式计算机设备验收单,电脑设备验收单.doc
  6. EDA实践——基于VHDL的循环八路彩灯设计
  7. 效果器的使用技巧-与调音台的无缝连接
  8. 网页监控系统设计之使用mjpg-streamer
  9. symbian赛班 系统介绍
  10. mozilla原代码编译