Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to find the intersection of two arrays.

Easy

Problem Statement

Write a program to find the intersection of two arrays.

Sample Input

arr1 = {1, 2, 3, 4, 5}, arr2 = {4, 5, 6, 7, 8}

Sample Output

Intersection = {4, 5}

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> #include <vector> int main() { std::vector<int> arr1 = {1, 2, 3, 4, 5}; std::vector<int> arr2 = {4, 5, 6, 7, 8}; // Logic to find intersection return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
arr1 = {1, 2, 3, 4, 5}, arr2 = {4, 5, 6, 7, 8}
Expected Output
Intersection = {4, 5}