Skip to content

Commit f593855

Browse files
committed
fixing ArrayIntersection
1 parent 215f5dc commit f593855

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Algorithms/LeetCode/ArrayIntersection.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ public static class ArrayIntersection
88
public static int[] Intersection(int[] nums1, int[] nums2)
99
{
1010
var intersection = new List<int>();
11-
var nums1set = new HashSet<int>(nums1);
12-
var nums2set = new HashSet<int>(nums2);
1311

1412
HashSet<int> larger, smaller;
1513

16-
if (nums1set.Count() > nums1set.Count())
14+
if (nums1.Count() > nums2.Count())
1715
{
18-
larger = nums1set;
19-
smaller = nums2set;
16+
larger = new HashSet<int>(nums1);
17+
smaller = new HashSet<int>(nums2);
2018
}
2119
else
2220
{
23-
larger = nums2set;
24-
smaller = nums1set;
21+
larger = new HashSet<int>(nums2);
22+
smaller = new HashSet<int>(nums1);
2523
}
2624

2725
foreach (var smallValue in smaller)

0 commit comments

Comments
 (0)