1, to the two arrays of integers A and B, common to two arrays, the longest length of the subarray.
Time complexity to be optimized
class Solution { public int findLength(int[] A, int[] B) { int l=0; int lena=A.length; int lenb=B.length; for(int i=0;i<lena;i++){ int temp=i; for(int j=0;j<lenb;j++){ int sl=0; int tmp=j; while(i<lena&&j<lenb&&A[i]==B[j]){ i++; j++; sl++; } if(sl>l){ l=sl; } i=temp; j=tmp; } } return l; } }