leetcode week18
来源:互联网 发布:python数据分析怎么样 编辑:程序博客网 时间:2024/05/21 11:24
Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following:
1. 12. 113. 214. 12115. 111221
1
is read off as "one 1"
or 11
.11
is read off as "two 1s"
or 21
.21
is read off as "one 2
, then one 1"
or 1211
.
class Solution {public: string countAndSay(int n) { if(n==1) return "1"; string str = countAndSay(n-1)+'*'; int count = 1; string out=""; for(int i=0;i<str.size()-1;i++) { if(str[i] == str[i+1]) count++; else { stringstream s; s << count; out = out+s.str()+str[i]; count=1; } } return out; }};
阅读全文
0 0
- Leetcode week18
- leetcode week18
- leetcode week18
- leetcode week18
- leetcode week18
- leetcode week18
- leetcode week18
- LeetCode Week18: Sicily Test
- 算法设计Week18 LeetCode Algorithms Problem #344 Integer Break
- week18- NO.128. Longest Consecutive Sequence
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode
- leetcode:
- leetcode:
- LeetCode
- 根据值来动态选中select option
- Java操作redis
- 欢迎使用CSDN-markdown编辑器
- UDP局域网广播实现CS房间列表
- JAVAWEB开发之SpringMVC详解(二)——高级开发、数据回显、参数绑定集合、图片上传、json交互、validation校验、异常处理、RESTful支持、拦截器
- leetcode week18
- Multiple Contexts have a path of "/xxxx"问题解决
- java提高篇(十四)-----关键字final
- HEEDS.MDO.2017.04
- Android 之 Material Design(三)—DrawerLayout+NavigationView+Toolbar(点击icon打开关闭侧滑菜单)
- DH的第一个博客
- 数据库连接池的配置和使用(大自然的搬运工)
- android6.0运行时权限
- 那个卖了房子去大理的姑娘,4个月后又回来了