what method f do: method "f" fill emptyArr with numbers of arr1 that the method "f" don't find in arr2 and return the biggest number in arr1 that the method "f" canot
find in arr2.
given information - arr1.length == arr2.length, arr1 and arr2 full with whole positive numbers.
qustion is : how to improve the time complexity of this method ???
public int f(intarr1, intarr2, int emptyArr)
int length = a.length;
int k = 0, g = 0, index = 0;
for(int i=0; i < length; i++)
for(int j=0; j < length; j++)
if(arr2[j] == arr1[i])
if(j == length)
if(g == 0 || emptyArr[index]> k) // find the max of arr1 that you don't have in arr2
k = emptyArr[index]; // max of arr1 that you don't have in arr2
g = 1;
return k; // max of arr1 that you don't have in arr2 .