Ad
  • Custom User Avatar

    Technically, his solution is more optimal than the other solutions given. If you use qsort (O(n2 log n2) on the avg. case) on arr2, and bsort on arr2 for every element in arr1 ((O(n1 log n2)), then you have a time complexity of O((n1 + n2) * log(n2)), while the complexity of the other solutions are O(n1 * n2).