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.
Maybe i'm missing something but trying the code from the editorial with:
str1="ac", str2="abc" and it returns 1 but
LCS(str1, str2) = 1 -------(a or c)
The only way to increment LCS is to put a 'b' in str1 in the 2° position so:
str1="ac"=========> str1="abc" and now LCS() = 3. In this case LCS is incermented by 2 not by 1 so there is not a way to increment the LCS by 1. So it should return 0.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
LCS Returns
You are viewing a single comment's thread. Return to all comments →
Maybe i'm missing something but trying the code from the editorial with:
str1="ac", str2="abc" and it returns 1 but
LCS(str1, str2) = 1 -------(a or c)
The only way to increment LCS is to put a 'b' in str1 in the 2° position so:
str1="ac"=========> str1="abc" and now LCS() = 3. In this case LCS is incermented by 2 not by 1 so there is not a way to increment the LCS by 1. So it should return 0.