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 ...
随机推荐
- ural1297 求最长回文子串 | 后缀数组
#include<cstdio> #include<algorithm> #include<cstring> #define N 20005 using names ...
- java 实验四
北京电子科技学院(BESTI) 实 验 报 告 课程: Java 班级:1352 姓名:黄卫 学号:201352221 成绩: ...
- 关于Mybatis的@Param注解 及 mybatis Mapper中各种传递参数的方法
原文:https://blog.csdn.net/mrqiang9001/article/details/79520436 关于Mybatis的@Param注解 Mybatis 作为一个轻量级的数 ...
- ubuntu 服务器搭建汇总
开启ssh 1.首先:终端安装开启ssh-server服务: sudo apt-get install openssh-server 2.然后确认sshserver是否启动了: ps-e | grep ...
- ufw坑
ufw就是一个iptables的快捷应用.今天被这个给坑了. 一个同时没事随便修改ufw,结果ssh登陆不上,ldap什么的都被阻断了. 直接iptables -F,结果忘了修改policy,直接没法 ...
- HDU1530 最大团 模板
Maximum Clique Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Maatkit--Mysql的高级管理工具
Maatkit是不错的mysql管理工具,已经成为Percona的一部分.包含以下主要工具: 1.mk-table-checksum 检查主从表是否一致的有效工具 2.mk-table-sync 有效 ...
- DEBUG宏
4.8.6.运算中的临时匿名变量4.8.6.1.C语言和汇编的区别(汇编完全对应机器操作,C对应逻辑操作)(1)C语言叫高级语言,汇编语言叫低级语言.(2)低级语言的意思是汇编语言和机器操作相对应,汇 ...
- 浏览器发送URL的编码特性
转载自:http://blog.csdn.net/wangjun_1218/article/details/4330244 浏览器发送URL的编码特性 尽管有很多规范URL的标准,例如RFC 3987 ...
- 游戏编程入门之Bomb Catcher游戏
首先是代码: MyDirectX.h: #pragma once //header file #define WIN32_EXTRA_LEAN #define DIRECTINPUT_VERSION ...