package leetcode;

/**
 * https://leetcode.com/problems/maximum-length-of-repeated-subarray/
 */
public class Problem718 {
    public int findLength(int[] A, int[] B) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem718 prob = new Problem718();
        System.out.println(prob.findLength(new int[]{1, 2, 3, 2, 1}, new int[]{3, 2, 1, 4, 7})); // 3
    }
}

@@ -174,32 +174,567 @@
     
-// TODO%0A        return 0
+return findLength(A, B, 0, 0);%0A    %7D%0A%0A    private static int findLength(int%5B%5D a, int%5B%5D b, int i, int j) %7B%0A        if (i == a.length) %7B%0A            return 0;%0A        %7D%0A        if (j == b.length) %7B%0A            return 0;%0A        %7D%0A        int max = 0;%0A        if (a%5Bi%5D == b%5Bj%5D) %7B%0A            int z = findLength(a, b, i + 1, j + 1) + 1;%0A            max = Math.max(max, z);%0A        %7D else %7B%0A            int x = findLength(a, b, i, j + 1);%0A            int y = findLength(a, b, i + 1, j);%0A            max = Math.max(max, Math.max(x, y));%0A        %7D%0A        return max
 ;%0A  
@@ -929,16 +929,121 @@
 ); // 3%0A
+        System.out.println(prob.findLength(new int%5B%5D%7B1, 2, 3, 2, 1%7D, new int%5B%5D%7B1, 3, 2, 1, 4, 7%7D)); // 3%0A
     %7D%0A%7D%0A

Update problem 718