Skip to content

Commit

Permalink
Add C# Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Jahir509 committed Nov 4, 2023
1 parent a27055d commit c20c0cc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions solution/0300-0399/0349.Intersection of Two Arrays/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,27 @@ class Solution {
}
```

### **C#**

```c#
public class Solution {
public int[] Intersection(int[] nums1, int[] nums2) {
List<int> result = new List<int>();
HashSet<int> arr1 = new(nums1);
HashSet<int> arr2 = new(nums2);
foreach (int item in arr1)
{
if (arr2.Contains(item))
{
result.Add(item);
}
}
return result.ToArray();

}
}
```

### **...**

```
Expand Down
16 changes: 16 additions & 0 deletions solution/0300-0399/0349.Intersection of Two Arrays/solution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Solution {
public int[] Intersection(int[] nums1, int[] nums2) {
List<int> result = new List<int>();
HashSet<int> arr1 = new(nums1);
HashSet<int> arr2 = new(nums2);
foreach (int item in arr1)
{
if (arr2.Contains(item))
{
result.Add(item);
}
}
return result.ToArray();

}
}

0 comments on commit c20c0cc

Please sign in to comment.