Hello i'm new in java and i'm sorry if my english is not very good
i have a question to solve and i cann't figure it out how to solve it
i have this class
public class B
{
public boolean what(int []arr1,int[] arr2,int num)
{
for (int i=0;i<arr1.length;i++)
for(int j=0;j<arr2.length;j++)
if (arr1[i]+arr2[j]==num)
return true;
return false;
}
}
the two arrays contains int
they are sorted from the smallest to the biggest numbers
i need to write another class with the same mathod
but in more efficient complexity (i think i need to do this in O(nlogn)beacuse here the complexity is n^2)