CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsHashing

Intersection of Two Arrays II

Easy
LeetCode
2/8
EasyHashingLeetCode #350

Multiset Intersection

Count frequencies of one array; walk the other and consume counts.

Examples

Example 1

Input

4
1 2 2 1
2
2 2

Output

2 2
Example 2

Input

3
4 9 5
5
9 4 9 8 4

Output

4 9

Stuck? Take a nudge

C++17Autosaves