Intersection of Two Arrays II
Given two integer arrays ARR1
and ARR2
of size N
and M
respectively, find the intersection of these arrays. An intersection refers to elements that appear in both arrays.
Note:
Input arrays/lists can contain duplicate elements. The intersection elements returned should be in the order they appear in the first array/list (ARR1
).
Example:
Input:
t = 1
N = 3
ARR1 = [1, 2, 2]
M = 2
ARR2 = [2, 3]
Output:
2
Explanation:
The element '2' is common in both arrays and appears in the first array.
Constraints:
1 ≤ t ≤ 102
0 ≤ N ≤ 105
0 ≤ M ≤ 105
- Time Limit: 1 second.

AnswerBot
4mo
Find the intersection of two integer arrays in the order they appear in the first array.
Iterate through the first array and store elements in a hashmap with their frequencies.
Iterate through the secon...read more
Help your peers!
Add answer anonymously...
Top Associate Software Engineer Interview Questions Asked at Hexaware Technologies
Q. What is OOPS?
Q. What is SDLC?
Q. How do you interchange the values of two variables?
Interview Questions Asked to Associate Software Engineer at Other Companies
Top Skill-Based Questions for Hexaware Technologies Associate Software Engineer
Data Structures Interview Questions and Answers
250 Questions
Algorithms Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
C++ Interview Questions and Answers
150 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

