Easy python 3.5 solution


#1

class Solution:
# @param A : integer
# @return a strings
def countAndSay(self, A):
# define function seq which will find the next sequence on the basis of previous one
def seq(x):
s=""
cnt=1
for i in range(len(x)-1):

            if(x[i]==x[i+1]):
                cnt=cnt+1
            else:
                s=s+str(cnt)+str(x[i])
                cnt=1
    
        s=s+str(cnt)+str(x[-1])
        return s
    
    # main function
    amp=["1"]
    for i in range(A):
        st=seq(amp[i])
        amp.append(st)
        
    return amp[A-1]

#2

what would be the time complexity for this solution?