Count and Say
这个题... 可能是用来娱乐的吧,也没有算法,反正就是暴力往前推就是了
class Solution(object):
def countAndSay(self, n):
"""
:type n: int
:rtype: str
"""
res = '1'
for i in xrange(0, n - 1):
tmp = ''
cur = res[0]
count = 0
for ch in res:
if ch == cur:
count += 1
else:
tmp += (str(count) + cur)
cur = ch
count = 1
res = tmp + str(count) + cur
return res