Leetcode刷题718公共最长数组

    技术2022-07-11  135

    public int findLength(int[] A, int[] B) { int max =0; for (int i = 0; i <A.length ; i++) { for (int j = 0; j <B.length ; j++) { int itemp=i; int jtemp=j; int temp =0; while (itemp<A.length&&jtemp<B.length&&A[itemp]==B[jtemp]){ temp++; itemp++; jtemp++; } max = Math.max(max,temp); } } return max; }
    Processed: 0.009, SQL: 9