标签:code and obj object nta span str self solution
主要是看懂题意,然后就是简单的递归.
class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ if n==1: return ‘1‘ else: sequence = self.countAndSay(n-1) left,right,num,size=0,0,0,len(sequence) ans=‘‘ while right<=size: if right == size: ans+=str(num)+sequence[left] break if sequence[right]==sequence[left]: num+=1 right+=1 else: ans+=str(num)+sequence[left] left=right num=0 return ans
标签:code and obj object nta span str self solution
原文地址:https://www.cnblogs.com/zywscq/p/10504033.html