class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ s='1' for i in range(2,n+1): s=self.count(s) return s def count(self,s): t='';count=0;curr='#' for i in s: if i != curr: if curr != '#': t+=str(count)+curr curr=i count=1 else: count+=1 t+=str(count)+curr return t
@link http://www.cnblogs.com/zuoyuan/p/3781329.html