I have 2 large integer arrays. I have to get the difference of these arrays(i.e. elements in 2nd array, not in 1st or vice versa). I am implementing a linear search and storing the difference in an array. Is there any way I can do it faster (Linear time)?
Share
It’s easy to get O(n+m) time if you put one array into a hash set and then run through the other array, probing the hash set. Of course, if your arrays were sorted, then you could have O(n+m) directly.