Here you can find the source of lcs(char[] inputString1, char[] inputString2, int length1, int length2)
private static int lcs(char[] inputString1, char[] inputString2, int length1, int length2)
//package com.java2s; //License from project: Open Source License public class Main { private static int lcs(char[] inputString1, char[] inputString2, int length1, int length2) { if (length1 == 0 || length2 == 0) return 0; if (inputString1[length1 - 1] == inputString2[length2 - 1]) return 1 + lcs(inputString1, inputString2, length1 - 1, length2 - 1);//from www . jav a 2s . c om else return Math.max( lcs(inputString1, inputString2, length1, length2 - 1), lcs(inputString1, inputString2, length1 - 1, length2)); } }