From ceda50e4be164ba8134dabe53f2c20d5207b0823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Zagrobelny?= Date: Sat, 27 Oct 2018 14:27:39 +0200 Subject: [PATCH] Added C# arrays intersector. --- Arrays/intersect_two_arrays.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Arrays/intersect_two_arrays.cs diff --git a/Arrays/intersect_two_arrays.cs b/Arrays/intersect_two_arrays.cs new file mode 100644 index 0000000..aa76f60 --- /dev/null +++ b/Arrays/intersect_two_arrays.cs @@ -0,0 +1,18 @@ +using System.Linq; + +namespace ArraysOperations +{ + public class ArrrayInteresector + { + public int[] IntersectArrays(int[] firstArray, int[] secondArray) + { + var setA = firstArray.ToHashSet(); + var setB = secondArray.ToHashSet(); + + setA.IntersectWith(setB); + var intersectArray = setA.ToArray(); + + return intersectArray; + } + } +} \ No newline at end of file