This is the algorithm I am trying to complete but don't know how to move forward ,
public int findArray(int[] array, int[] subArray) {
for (int i = 0; i < array.length; i++) {
for (int j = 0; i < subArray.length; j++) {
if (array[i] == subarray[j]) {//not sure if this is how to start
}
}//will want to compare all element in subarray to Array
}
return 0;
}
My desired result would be as follows
//[4,9,3,7,8] and [3,7] should return 2.
//[7,8,9] and [8,9,10] should return -1
//[4,9,3,7,8,3,7,1] and [3,7]should return 5
My understanding is I take subarray as whole and try to find where it matches in the array but don't know how to go about it