class Solution {
public:
vector<string> vs_;
Solution(){
string t("");
vs_.push_back(t);
for(int i = ; i< ;++i){
string t1 = vs_[i - ];
t = "";
int cnt = ,j ; for(j = ; j < t1.size() - ; ++j){
if(t1[j] == t1[j + ]){
++cnt;
}
else{
char s[] ="";
sprintf(s,"%d%c",cnt,t1[j]);
t += string(s);
cnt = ;
}
}
char s[] ="";
sprintf(s,"%d%c",cnt,t1[j]);
t += string(s);
vs_.push_back(t);
}
}
~Solution(){
vs_.clear();
} string countAndSay(int n) {
return vs_[n-];
}
};

Leetcode 38 Count and Say 传说中的递推的更多相关文章

  1. LeetCode - 38. Count and Say

    38. Count and Say Problem's Link ------------------------------------------------------------------- ...

  2. Leetcode 119 Pascal's Triangle II 数论递推

    杨辉三角,这次要输出第rowIndex行 用滚动数组t进行递推 t[(i+1)%2][j] = t[i%2][j] + t[i%2][j - 1]; class Solution { public: ...

  3. LeetCode 38 Count and Say(字符串规律输出)

    题目链接:https://leetcode.com/problems/count-and-say/?tab=Description   1—>11—>21—>1211—>111 ...

  4. [LeetCode] 38. Count and Say 计数和读法

    The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 ...

  5. Java [leetcode 38]Count and Say

    题目描述: The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, ...

  6. [leetcode]38. Count and Say数数

    The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 ...

  7. [LeetCode] 38. Count and Say_Easy

    The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 ...

  8. leetcode 38 Count and Say ---java

    这道题主要就是求一个序列,题目得意思就是 1 --> 11 --> 21 --> 1211 -->   111221 --> 312211 --> ..... 1个 ...

  9. LeetCode - 38. Count and Say(36ms)

    The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 ...

随机推荐

  1. Selenium2+python自动化25-js处理日历控件(修改readonly属性)

    前言 日历控件是web网站上经常会遇到的一个场景,有些输入框是可以直接输入日期的,有些不能,以我们经常抢票的12306网站为例,详细讲解如何解决日历控件为readonly属性的问题. 基本思路:先用j ...

  2. node.js 基础学习笔记1

    1. node -v 查看版本 node -e --js代码 node --进入编辑模式 Ctrl+C 退出编译模式 var http=require('http') http.createServe ...

  3. ByteArrayInputStream和ByteArrayOutputStream

    public class ByteArrayTest { public static void main(String[] args) throws IOException { read(write( ...

  4. bootstrap的日期插件datetimepicker有问题

    bootstrap的日期插件datetimepicker在chrome中会出现掉下来的现象,而且一直没找到原因,下载最新版的插件直接在各个浏览器中都会掉下来, 问题一直解决不了,转而换其他插件 htt ...

  5. javascript this

    最近看了很多人的微博,主要是“追梦子”的微博,总结了一下.希望大家多多指点. 1. 没有new this的指向问题   this的指向在函数创建的时候是决定不了的,在调用的时候才能决定,谁调用的就指向 ...

  6. zabbix使用host metadata方式主动注册

    host metadata是zabbix2.2新增加的功能,该功能在zabbix-agent端可以自定义条件,在选择自动注册的时候,zabbix-server端可以根据host metadata来选择 ...

  7. 浏览器js console对象

    js中调用console写日志 console.log("some log"); console.warn("some warning"); console.e ...

  8. java有符号无符号的转换

    数据处理中常常遇到基本数据类型的操作,java都是有符号的数据,而与下位机通信中常常遇到无符号的比如uint8, uint16,uint32等等 1.为了完成这个功能还专门采用ByteBuffer的方 ...

  9. Android的项目不能直接引用可移植类库的项目解决方法

    深圳_exception() 10:25:51 Android的项目不能直接引用可移植类库的项目,但是可以引用可移植类库生成的dll,这就意味着无法直接断电调试可移植类库上海-黄药师() 10:26: ...

  10. C#设计模式——抽象工厂

    一.引言 我相信看到这段文字的人,都具备了良好的技术功底.但是对于自己编写的代码总是充满抱怨,希望能够将自己编写的代码如同房子一般先进行有效 的设计,然后在进行建设.那么这篇文章能够给你一些思路,这里 ...