Python solution o(n^2) complexity


#1

class Solution:
# @param A : integer
# @return a strings
def countAndSay(self, A):

    if(A==1):
        return '1'
    if(A==2):
        return '11'
    
    #num='11'
    count=1
    j=0
    res='11'
    check=False
    
    for i in range(2,A):
        j=1
        count=1
        num=res
        res=''
        while(j<len(num)):
            if(num[j]==num[j-1]):
                count+=1
                j+=1
            else:
                res+=str(count)+num[j-1]
                count=1
                j+=1
        
        res+=str(count)+num[j-1]
       
    return res