Sort by

recency

|

29 Discussions

|

  • + 0 comments

    I might be too late but the solution would be to declare it globally. There isn't enough space available in the function segment. For more details visit the glass fitting supplier Dubai.

  • + 0 comments

    I might be too late but the solution would be to declare it globally. There isn't enough space available in the function segment. For more details visit the monk ice bath UK.

  • + 0 comments

    I might be too late but the solution would be to declare it globally. There isn't enough space available in the function segment. For more details visit the portal.

  • + 0 comments

    What is wrong withthe code:

    memo=[[0]*(len(s2)+1) for _ in range((len(s1)+1))]        
        for i in range(1, len(s1)+1):
            for j in range(1, len(s2)+1):          
                if s1[i-1]==s2[j-1] :          
                    memo[i][j]=memo[i-1][j-1]+1
                else:
                    memo[i][j]=max(memo[i-1][j], memo[i][j-1])
                                    
        _cur=memo[-1][-1]
        suffixes=[[0]*(len(s2)+1) for _ in range((len(s1)+1))] 
        print(memo)      
        for i in range(len(s1)-1, -1, -1):
            for j in range(len(s2)-1, -1, -1):
                print(s1[i], s2[j])
                if s1[i]==s2[j]:   
                    suffixes[i][j]=suffixes[i+1][j+1]+1
                else:
                    suffixes[i][j]=max(suffixes[i+1][j], suffixes[i][j+1]) 
        count=0
        print(suffixes)
        for i in range(len(s1)+1):
            seen=set()
            for j in range(len(s2)):
                if memo[i][j]+suffixes[i][j+1]+1>_cur:
                    count+=1
                    seen.add(s2[j])
        return count
    
  • + 0 comments

    What is wrong withthe code:

    memo=[[0]*(len(s2)+1) for _ in range((len(s1)+1))]        
        for i in range(1, len(s1)+1):
            for j in range(1, len(s2)+1):          
                if s1[i-1]==s2[j-1] :          
                    memo[i][j]=memo[i-1][j-1]+1
                else:
                    memo[i][j]=max(memo[i-1][j], memo[i][j-1])
                                    
        _cur=memo[-1][-1]
        suffixes=[[0]*(len(s2)+1) for _ in range((len(s1)+1))] 
        print(memo)      
        for i in range(len(s1)-1, -1, -1):
            for j in range(len(s2)-1, -1, -1):
                print(s1[i], s2[j])
                if s1[i]==s2[j]:   
                    suffixes[i][j]=suffixes[i+1][j+1]+1
                else:
                    suffixes[i][j]=max(suffixes[i+1][j], suffixes[i][j+1]) 
        count=0
        print(suffixes)
        for i in range(len(s1)+1):
            seen=set()
            for j in range(len(s2)):
                if memo[i][j]+suffixes[i][j+1]+1>_cur:
                    count+=1
                    seen.add(s2[j])
        return count