LeetCode-38-Count and Say Python的int_to_string

来源:互联网 发布:移动网络玩战舰世界 编辑:程序博客网 时间:2024/06/05 09:30

题意真的很难理解。。。

class Solution(object):    def countAndSay(self, n):        """        :type n: int        :rtype: str        """        if n==1:return "1"        s="1"        for i in range(n-1):            p=0;            nexts=""            while(p<len(s)):                startp=p                while(p<len(s) and s[p]==s[startp]):                    p+=1                nexts+=str(p-startp)+s[startp]            s=nexts            #print s        return s            


原创粉丝点击