@@ -0,0 +1,868 @@
+/**%0A * Created by gungr on 9/11/2016.%0A */%0Apublic class LongestCommonSubstring %7B%0A%0A    public static int longestSubstring(String s1, String s2) %7B%0A        if(s1.length() == 0 %7C%7C s2.length() == 0)%0A            return 0;%0A%0A        int max = 0;%0A        int lengthS1 = s1.length();%0A        int lengthS2 = s2.length();%0A        int%5B%5D%5B%5D table = new int%5BlengthS1 + 1%5D%5BlengthS2 + 1%5D;%0A%0A        for(int i = 1; i %3C= lengthS1; i++) %7B%0A            for(int j = 1; j %3C= lengthS2; j++) %7B%0A                if(s1.charAt(i-1) == s2.charAt(j-1))%0A                    table%5Bi%5D%5Bj%5D = table%5Bi-1%5D%5Bj-1%5D + 1;%0A                if(table%5Bi%5D%5Bj%5D %3E max)%0A                    max = table%5Bi%5D%5Bj%5D;%0A            %7D%0A        %7D%0A        return max;%0A    %7D%0A%0A%0A    public static void main(String%5B%5D argv) %7B%0A        String s1 = %22abcdaf%22;%0A        String s2 = %223bcdf%22;%0A        System.out.println(longestSubstring(s1, s2));%0A    %7D%0A%7D%0A

longest common substring