my python solution


  • 0
    Z
    class Solution(object):
        def countAndSay(self, n):
            if n==1:
                return "1"
            else:
                count=[1]
                for i in range(n-1):
                    a=count[0]
                    count.append("X")
                    n=0
                    lis=[]
                    for j in range(len(count)):
                        if a==count[j]:
                            n+=1
                        else:
                            lis.append(str(n))
                            lis.append(str(a))
                            a=count[j]
                            n=0
                            n+=1
                    count=lis
                return "".join(count)
    

    any suggestions please tell me


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.