leetcode 外观数列
class Solution(object):
def countAndSay(self, n):
a='1'
def count(pre):
start=0
end=0
cur=''
while end<len(pre):
while end<len(pre) and pre[start]==pre[end]:
end+=1
cur=cur+str(end-start)+pre[start]
# print(cur)
start=end
return cur
for k in range(n-1):
a=count(a)
#print(a)
return a
n=3
c=Solution()
import time
t1=time.time()
#计算几个数之和,下面就填几
c1=c.countAndSay( 4)
print(time.time()-t1)
print(c1)