@@ -0,0 +1,980 @@
+package MaximumLengthofRepeatedSubarray;%0A%0A%0A/**%0A * Given two integer arrays A and B, return the maximum length of an subarray that%0A * appears in both arrays.%0A * %3Cpre%3E%0A * Example 1:%0A * Input:%0A * A: %5B1,2,3,2,1%5D%0A * B: %5B3,2,1,4,7%5D%0A * Output: 3%0A * Explanation:%0A * The repeated subarray with maximum length is %5B3, 2, 1%5D.%0A * Note:%0A * 1 %3C= len(A), len(B) %3C= 1000%0A * 0 %3C= A%5Bi%5D, B%5Bi%5D %3C 100%0A * %3C/pre%3E%0A */%0Aclass Solution %7B%0A%0A    public int findLength(int%5B%5D A, int%5B%5D B) %7B%0A        int l, r;%0A        l = A.length;%0A        r = B.length;%0A        int%5B%5D%5B%5D count = new int%5Bl%5D%5Br%5D;%0A%0A        int s = 0;%0A%0A        for (int i = 0; i %3C l; i++) %7B%0A            for (int j = 0; j %3C r; j++) %7B%0A                if (A%5Bi%5D == B%5Bj%5D) %7B%0A                    count%5Bi%5D%5Bj%5D = 1 + (i %3E 0 && j %3E 0 ? count%5Bi - 1%5D%5Bj - 1%5D : 0);%0A                %7D else %7B%0A                    count%5Bi%5D%5Bj%5D = 0;%0A                %7D%0A                if (s %3C count%5Bi%5D%5Bj%5D)%0A                    s = count%5Bi%5D%5Bj%5D;%0A            %7D%0A        %7D%0A        return s;%0A    %7D%0A%7D

Add #Maximum Length of Repeated Subarray