Intersection of Two Arrays II
@ico-Meng @jack76 Thank you for the info!
I think the contain() method in hashmap can take O(n) time. Instead, I used a hashset to check whether the key is included or not.
@xsh6528 u are right,there is no auxiliary space usead
I also get one simple solution
@ningzhao Thank you so much for your explanations!
Using a unordered_multiset, hope it helps!
No one has replied
@tobelzm I don't think so, for the 2 pointer way, each array will have one pointer and if the pointed values are the same, add it to returned list and move the first pointer, if not, move the second pointer to the next.
And it does it a lot faster:
could you explain your answers for followup2 and 3?
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.