Here you can find the source of lcs(String arg0, String arg1)
public static long lcs(String arg0, String arg1)
//package com.java2s; //License from project: Open Source License public class Main { public static long lcs(String arg0, String arg1) { if (arg0 == null || arg1 == null) { return 0; }//from w ww . j a v a2 s . com return lcs(arg0, arg1, 0, 0); } private static long lcs(String arg0, String arg1, int i, int j) { if (arg0.length() == i || arg1.length() == j) { return 0; } if (arg0.charAt(i) == arg1.charAt(j)) { return 1 + lcs(arg0, arg1, ++i, ++j); } else { return Math.max(lcs(arg0, arg1, ++i, j), lcs(arg0, arg1, i, ++j)); } } }