Since the arrays are sorted, you can use a binary search for this problem. That would make the what method n(log n). Take the middle value of the array and compare it to the value you are searching for. You found your answer if the values match. Or the value you are searching for would be in the first half of the array if the middle value is greater than the value you are searching for. Or the value you are searching for is in the second half of the array if the middle value is less than the value you are searching for. Now take the half of the array where value is located and repeat the same procedure. You are splitting the array in half every time you do this. Which makes binary search a log n operation. Since you are searching for n values from array 1, your what method will be n(log n).