package leetcode;

/**
 * https://leetcode.com/problems/longest-common-subsequence/
 */
public class Problem1143 {
    public int longestCommonSubsequence(String text1, String text2) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1143 prob = new Problem1143();
        System.out.println(prob.longestCommonSubsequence("abcde", "ace")); // 3
        System.out.println(prob.longestCommonSubsequence("ace", "abcde")); // 3
        System.out.println(prob.longestCommonSubsequence("abc", "abc")); // 3
        System.out.println(prob.longestCommonSubsequence("abc", "def")); // 0
    }
}

@@ -190,32 +190,625 @@
     
-// TODO%0A        return 0
+return longestCommonSubsequence(text1, text2, 0, 0);%0A    %7D%0A%0A    private static int longestCommonSubsequence(String text1, String text2, int i, int j) %7B%0A        if (i == text1.length()) %7B%0A            return 0;%0A        %7D%0A        if (j == text2.length()) %7B%0A            return 0;%0A        %7D%0A        int value;%0A        if (text1.charAt(i) == text2.charAt(j)) %7B%0A            value = longestCommonSubsequence(text1, text2, i + 1, j + 1) + 1;%0A        %7D else %7B%0A            value = longestCommonSubsequence(text1, text2, i + 1, j) +%0A                longestCommonSubsequence(text1, text2, i, j + 1);%0A        %7D%0A        return value
 ;%0A  
@@ -975,32 +975,34 @@
 , %22ace%22)); // 3%0A
+//
         System.o
@@ -1057,32 +1057,34 @@
 %22abcde%22)); // 3%0A
+//
         System.o
@@ -1145,16 +1145,18 @@
 ); // 3%0A
+//
         

Update problem 1143