I would like to know the algorithm to determine the intersection of two arrays of equal elements (say, integer) without using any external data structure (like hash table) e
sort, then iterate using an iterator to each element array:
if A[iter1] > B[iter2]: increase iter2 else if A[iter1] < B[iter2]: increase iter1 else: element is in intersection, print and increase both iters
Sorting is O(nlogn), iterating is O(n), total O(nlogn)
O(nlogn)
O(n)