string countAndSay(int n)
{
string res;
if (n <= )
return res; res = "";
while (n-- > ) {
int len = res.size();
int i, j;
string resTmp; for (i = ; i < len; i = j) {
char ch = res[i]; for (j = i + ; j < len; ++j) {
if (ch != res[j])
break;
} resTmp = resTmp + (char)(j - i + '') + ch;
}
res = resTmp;
}
return res;
}

【LeetCode 38_字符串_算术运算】Count and Say的更多相关文章

  1. 【LeetCode 67_字符串_算术运算】Add Binary

    string addBinary(string a, string b) { int alen = a.size(); int blen = b.size(); ) return b; ) retur ...

  2. 【LeetCode 8_字符串_实现】String to Integer (atoi)

    , INVALID}; int g_status; long long SubStrToInt(const char* str, bool minus) { ; : ; while (*str != ...

  3. 【LeetCode 28_字符串_匹配】Implement strStr()

    解法一:Brute-force int strStr(string haystack, string needle) { int m = haystack.size(); int n = needle ...

  4. 1.Python_字符串_常用办法总结

    明确:对字符串的操作方法都不会改变原来字符串的值. 1.去掉空格和特殊符号 name.strip() 去掉空格和换行符 name.strip("xx") 去掉某个字符串 name. ...

  5. Leetcode中字符串总结

    本文是个人对LeetCode中字符串类型题目的总结,纯属个人感悟,若有不妥的地方,欢迎指出. 一.有关数字 1.数转换 题Interger to roman和Roman to integer这两题是罗 ...

  6. LeetCode:字符串相加【415】

    LeetCode:字符串相加[415] 题目描述 给定两个字符串形式的非负整数 num1 和num2 ,计算它们的和. 注意: num1 和num2 的长度都小于 5100.num1 和num2 都只 ...

  7. jquery中如何以逗号分割字符串_百度知道

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...

  8. BZOJ_4002_[JLOI2015]有意义的字符串_矩阵乘法

    BZOJ_4002_[JLOI2015]有意义的字符串_矩阵乘法 Description B 君有两个好朋友,他们叫宁宁和冉冉.有一天,冉冉遇到了一个有趣的题目:输入 b;d;n,求 Input 一行 ...

  9. LeetCode:字符串的排列【567】

    LeetCode:字符串的排列[567] 题目描述 给定两个字符串 s1 和 s2,写一个函数来判断 s2 是否包含 s1 的排列. 换句话说,第一个字符串的排列之一是第二个字符串的子串. 示例1: ...

随机推荐

  1. Nginx rewrite 中break与last指令的区别

    location /break/ { rewrite ^/break/(.*) /test/$1 break; return 402; } location /last/ { rewrite ^/la ...

  2. [随感]GIS开发的困惑

    从事GIS应用开发也有3年了,但是做了些东西自己始终不满意,不是不稳定就是效率低,不是功能杂就是不实用! 首先是AE开发,我必须说自己很欣赏ArcGIS的软件设计架构和思想.但是在开发的过程中也确实遇 ...

  3. python 实现的比特币代码 及 加密货币学习线路图及书籍资料

    http://www.pycoind.org/ https://github.com/samrushing/caesure https://bitcointalk.org/index.php?topi ...

  4. python模块之subprocess模块

    简述 subprocess意在替代其他几个老的模块或者函数,比如:os.system os.spawn* os.popen* popen2.* commands.*subprocess最简单的用法就是 ...

  5. django基于cors做跨域处理

    背景知识:跨域相关与cors策略 1.安装django-cors-headers pip install django-cors-headers 2.settings.py配置 INSTALLED_A ...

  6. PAT 1105 Spiral Matrix[模拟][螺旋矩阵][难]

    1105 Spiral Matrix(25 分) This time your job is to fill a sequence of N positive integers into a spir ...

  7. Flask目录

    Flask Python数据库连接池DBUtils 单例模式 flask—信号(blinker) Flask-SQLAlchemy flask扩展 -- flask-script Flask form ...

  8. 5.2 Components — Defining A Component

    一.概述 1. 为了定义一个组件,创建一个模板,它的名字以components/开头.为了定义一个新组件{{blog-post}},例如,创建一个components/blog-post模板. 2.注 ...

  9. Educational Codeforces Round 54 (Rated for Div. 2) Solution

    A - Minimizing the String solved 题意:给出一个字符串,可以移掉最多一个字符,在所有可能性中选取一个字典序最小的. 思路:显然,一定可以移掉一个字符,如果移掉的字符的后 ...

  10. .net core 2.2 & Mongodb

    .net core 2.2 API项目中使用Mongodb 简单的CRUD封装 创建FoodPlan.Core 项目 创建IEntityBase.cs 接口约束 创建Single.cs 实体 IEnt ...