We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defcommonChild(s1,s2):n=len(s1)# Create a 2D array to store the lengths of the common childdp=[[0]*(n+1)for_inrange(n+1)]foriinrange(1,n+1):forjinrange(1,n+1):ifs1[i-1]==s2[j-1]:dp[i][j]=dp[i-1][j-1]+1else:dp[i][j]=max(dp[i-1][j],dp[i][j-1])returndp[n][n]
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Common Child
You are viewing a single comment's thread. Return to all comments →