LPS algorithm fix

This commit is contained in:
mmessmer
2020-10-09 10:59:20 +02:00
parent 1bf0fe05a2
commit 196fcb30df

View File

@ -22,11 +22,11 @@ public class LongestPalindromicSubsequence {
StringBuilder reverse = new StringBuilder();
reverse.append(original);
reverse = reverse.reverse();
return recursiveLPS(original, reverse);
return recursiveLPS(original, reverse.toString());
}
private static String recursiveLPS(String original, String reverse) {
String bestResult = ""
String bestResult = "";
//no more chars, then return empty
if(original.length() == 0 || reverse.length() == 0) {