We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 215f5dc commit f593855Copy full SHA for f593855
Algorithms/LeetCode/ArrayIntersection.cs
@@ -8,20 +8,18 @@ public static class ArrayIntersection
8
public static int[] Intersection(int[] nums1, int[] nums2)
9
{
10
var intersection = new List<int>();
11
- var nums1set = new HashSet<int>(nums1);
12
- var nums2set = new HashSet<int>(nums2);
13
14
HashSet<int> larger, smaller;
15
16
- if (nums1set.Count() > nums1set.Count())
+ if (nums1.Count() > nums2.Count())
17
18
- larger = nums1set;
19
- smaller = nums2set;
+ larger = new HashSet<int>(nums1);
+ smaller = new HashSet<int>(nums2);
20
}
21
else
22
23
- larger = nums2set;
24
- smaller = nums1set;
+ larger = new HashSet<int>(nums2);
+ smaller = new HashSet<int>(nums1);
25
26
27
foreach (var smallValue in smaller)
0 commit comments