Link Search Menu Expand Document

Intersection

For the given arrays of integers a1 and a2, find all the items that belong to both a1 and a2.

E.g. for the following input:

var a1 = new[] { 1, 5, 10, 8 };
var a2 = new[] { 6, 8, 17, 4, 1 };

The output should be: 1, 8

Hint 1: This is where nested loops come in handy.