<LeetCode><Easy> 38 Count and Say
来源:互联网 发布:mac 10.12.6系统怎么样 编辑:程序博客网 时间:2024/06/15 18:10
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 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
.
Given an integer n, generate the nth sequence.
Note: The sequence of integers will be represented as a string.
#Python2 68ms
class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ def H(x): rList,count,tmp="",0,x[0] for i in range(len(x)): if x[i] == tmp: count+=1 else: rList,tmp,count=rList+str(count)+tmp,x[i],1 return rList+str(count)+tmp x='1' for i in range(n-1): x=H(x) return x
0 0
- [Leetcode 38, Easy] Count and Say
- <LeetCode><Easy> 38 Count and Say
- LeetCode-38-Count and Say(String/递归)-Easy
- Leetcode 38. Count and Say (Easy) (cpp)
- Count and say[easy on LeetCode]
- Easy 38题 Count and Say
- Easy 11 Count and Say(38)
- [LeetCode 38] Count and Say
- LeetCode(38) Count and Say
- [leetcode 38] Count and Say
- [Leetcode] 38 - Count and Say
- leetcode-38 count and say
- [LeetCode 38]Count and Say
- LeetCode 38 Count and Say
- leetcode-38 Count and Say
- Leetcode 38 Count and Say
- Leetcode---(38)Count and Say
- leetcode 38: Count and Say
- Github API 库的JSON文件格式
- AsyncTask
- Mysql删除所有表不删除数据库方法
- 测试管理QC
- 一个带有属性的字符串(比如文字颜色/字体属性等文字属性) 在label上显示需要使用 attributedText 属性
- <LeetCode><Easy> 38 Count and Say
- hibernate与mybatis比较
- Opencv+Kinect2.0获取BodyIndex图像
- InetAddress类的常用方法介绍
- shell命令
- GPU编程
- 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis
- Codevs P1653 种树 2
- 圆排列问题