class MaxString
{
public static void main(String[] arg)
{
String s1="kkjjoibidio";
String s2="kcjjonbidi";
String max=(s1.length()<s2.length())? s2:s1;
String min=(max==s1)?s2:s1;
System.out.println(run(max,min));
}
public static String run(String max,String min)
{
for (int x=0;x<min.length();x++ )
{
for (int y=0;y<=x ;y++ )
{
String ss=min.substring(y,min.length()-x+y);
if (max.contains(ss))
{
return ss;
}
}
}
return "";
}
}
|
|