Java LCS lcs(char[] inputString1, char[] inputString2, int length1, int length2)

Here you can find the source of lcs(char[] inputString1, char[] inputString2, int length1, int length2)

Description

lcs

License

Open Source License

Declaration

private static int lcs(char[] inputString1, char[] inputString2,
            int length1, int length2) 

Method Source Code

//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));
    }
}

Related

  1. lcs(char[] A, char[] B)
  2. LCS(String a, String b)
  3. lcs(String a, String b)
  4. LCS(String A, String B)
  5. lcs(String a, String b)