python leetcode38 递归
来源:互联网 发布:爷爷9岁被鬼子杀了知乎 编辑:程序博客网 时间:2024/06/05 12:12
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.
class Solution(object):
def countAndSay(self,n):
if n == 1:
return “1”
else:
b = self.countAndSay(n-1)
return self.count(b)
def count(self,b):
a = “”
c = 0
i = 0
while (i < len(b)):
eql = b[i]
while b[i] == eql:
c += 1
i += 1
if i == len(b):
break
a += (str(c) + b[i - 1])
c = 0
return a
- python leetcode38 递归
- java leetcode38 递归 4ms
- LeetCode38
- Leetcode38
- [LeetCode38]Count and Say
- Leetcode38: Rectangle Area
- Leetcode38 Count and Say
- leetcode38 Count and Say
- leetcode38---Count and Say
- leetcode38. Count and Say
- leetcode38: Count and Say
- Leetcode38: Count and Say
- LeetCode38. Count and Say
- leetcode38. Count and Say
- Python递归
- Python递归
- python递归
- Python | 递归
- centos 7 安装JDK 1.8
- 设置键盘弹起后整个View处于键盘上方
- CGAL4.9+boost1.59+QT5.6+vs2015 64bit+windows10配置
- NS3目录结构和相关模块
- Eclipse启动Tomcat时的问题
- python leetcode38 递归
- 深入理解C++中的深拷贝与浅拷贝
- 面试笔试题目(参考)
- ANSYS中Beam188\Beam189单元命令流提取最大应力
- 如何判断Linux的tar.gz是二进制文件还是源码文件
- 状态模式
- oracle 排序是,如果为null, 降序则排在最前面,怎么让这些null值排在最后面。 Nulls last
- C++对象的构造顺序
- CentOS通过YUM升级centOS内核