I'm not sure, but I think, the lines
else if (a.charAt(alen-1)==b.charAt(blen-1)){
return lcs(a.substring(0,alen-1),b.substring(0,blen-1));
}
should be changed to
else if (a.charAt(alen-1)==b.charAt(blen-1)){
return lcs(a.substring(0,alen-1),b.substring(0,blen-1)) + a.charAt(alen-1);
}
Otherwise no concatenation of strings takes place and only ""
is returned.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…