62,621
社区成员
发帖
与我相关
我的任务
分享public class LCS2
{
public static String printLCS2(char[] x, char[] y, int i, int j)
{
if (x[i - 1] == y[j - 1])
{
return printLCS2(x, y, i - 1, j - 1)+ String.valueOf(x[i - 1]);
} else if(printLCS2(x, y, i - 1, j).length() > printLCS2(x, y, i,j - 1).length())
{
return printLCS2(x, y, i - 1, j);
}
}
}
public static String printLCS2(char[] x, char[] y, int i, int j)
{
if (x[i - 1] == y[j - 1])
{
return printLCS2(x, y, i - 1, j - 1)+ String.valueOf(x[i - 1]);
} else if(printLCS2(x, y, i - 1, j).length() > printLCS2(x, y, i,j - 1).length())
{
return printLCS2(x, y, i - 1, j);
}
return null;
}

public static String printLCS2(char[] x, char[] y, int i, int j)
{
if (x[i - 1] == y[j - 1])
{
return printLCS2(x, y, i - 1, j - 1)+ String.valueOf(x[i - 1]);
} else if(printLCS2(x, y, i - 1, j).length() > printLCS2(x, y, i,j - 1).length())
{
return printLCS2(x, y, i - 1, j);
} else {
return "你要返回的值";//少这个
}
}