Leetcode 之Count and Say(35)

很有意思的一道题,不好想啊。
string getNext(string &s)
{
char start = s[];
int count = ;
stringstream ss;
for (int i = ; i < s.size(); i++)
{
if (start == s[i])
{
count++;
}
else
{
ss << count << start;
count = ;
start = s[i];
}
}
ss << count << start; return ss.str();
} string countAndSay(int n)
{
string s = "";
for (int i = ; i < n; i++)
s = getNext(s);
}
Leetcode 之Count and Say(35)的更多相关文章
- [LeetCode] 038. Count and Say (Easy) (C++/Python)
索引:[LeetCode] Leetcode 题解索引 (C++/Java/Python/Sql) Github: https://github.com/illuz/leetcode 038. Cou ...
- leetcode 315. Count of Smaller Numbers After Self 两种思路(欢迎探讨更优解法)
说来惭愧,已经四个月没有切 leetcode 上的题目了. 虽然工作中很少(几乎)没有用到什么高级算法,数据结构,但是我一直坚信 "任何语言都会过时,只有数据结构和算法才能永恒". ...
- leetcode 315. Count of Smaller Numbers After Self 两种思路
说来惭愧,已经四个月没有切 leetcode 上的题目了. 虽然工作中很少(几乎)没有用到什么高级算法,数据结构,但是我一直坚信 "任何语言都会过时,只有数据结构和算法才能永恒". ...
- 【算法之美】你可能想不到的归并排序的神奇应用 — leetcode 327. Count of Range Sum
又是一道有意思的题目,Count of Range Sum.(PS:leetcode 我已经做了 190 道,欢迎围观全部题解 https://github.com/hanzichi/leetcode ...
- leetcode@ [327] Count of Range Sum (Binary Search)
https://leetcode.com/problems/count-of-range-sum/ Given an integer array nums, return the number of ...
- LeetCode 204. Count Primes (质数的个数)
Description: Count the number of prime numbers less than a non-negative number, n. 题目标签:Hash Table 题 ...
- leetcode 730 Count Different Palindromic Subsequences
题目链接: https://leetcode.com/problems/count-different-palindromic-subsequences/description/ 730.Count ...
- LeetCode 38 Count and Say(字符串规律输出)
题目链接:https://leetcode.com/problems/count-and-say/?tab=Description 1—>11—>21—>1211—>111 ...
- [leetcode] 204. Count Primes 统计小于非负整数n的素数的个数
题目大意 https://leetcode.com/problems/count-primes/description/ 204. Count Primes Count the number of p ...
随机推荐
- CentOS 装hadoop3.0.3 版本踩坑
1.but there is no HDFS_NAMENODE_USER defined. Aborting operation. [root@xcff sbin]# ./start-dfs.sh S ...
- POJ1422:Air Raid——题解
http://poj.org/problem?id=1422 题目大意:n个点m条有向边,每条边只能走一次,往点上放人让他们走遍所有边,问至少要多少人. —————————————————————— ...
- POJ3461:Oulipo——题解
http://poj.org/problem?id=3461 KMP板子,好久以前学过了,直接把板子粘上去即可. #include<cstdio> #include<cstring& ...
- BZOJ1010:[HNOI2008]玩具装箱——题解
http://www.lydsy.com/JudgeOnline/problem.php?id=1010 P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行 ...
- POJ.3624 Charm Bracelet(DP 01背包)
POJ.3624 Charm Bracelet(DP 01背包) 题意分析 裸01背包 代码总览 #include <iostream> #include <cstdio> # ...
- [LOJ 6004] 圆桌聚餐
link 其实网络流就是再考你如何去建边. 先见$S$,$T$为源点与汇点,然后将$S$连向每一个单位,流量为每个单位的人数,然后将每一个单位连向每一个餐桌,流量为$1$,最后在将每一个餐桌与$T$相 ...
- js push
$('.main_div').each(function(){ product_id = parseInt($(this).data('id')); product_num = parseInt($( ...
- php中error_reporting
error_reporting(255);是列出所有提示error_reporting(0);是不显示所有提示建议使用error_reporting(7);只显示严重错误1 E_ERROR 致命的运行 ...
- 第一篇 关于Android Studio的快捷键
公司最近要培训Android的课程,但是发现现在官方网站上已经不提供了Eclipse ADT的下载了,都变成了Android Studio,可能是悲催了! 对于很多Eclipse转过来的同学,不适应的 ...
- 与http协作的web服务器、http首部(第五章、第六章)
第五章 与http协作的web服务器 1.用单台虚拟主机实现多个域名 通过域名访问主机,经过DNS解析成ip地址,反向代理,可以代理多台服务器,正向代理则相反,代理客户端 2.通信数据转化程序:代理. ...