Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c86b148

Browse files
add 2215
1 parent bf90263 commit c86b148

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-------------|-------------
11+
| 2215 |[Find the Difference of Two Arrays](https://leetcode.com/problems/find-the-difference-of-two-arrays/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2215.java) || Easy ||
1112
| 2210 |[Count Hills and Valleys in an Array](https://leetcode.com/problems/count-hills-and-valleys-in-an-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2210.java) || Easy ||
1213
| 2208 |[Minimum Operations to Halve Array Sum](https://leetcode.com/problems/minimum-operations-to-halve-array-sum/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2208.java) || Medium ||
1314
| 2206 |[Divide Array Into Equal Pairs](https://leetcode.com/problems/divide-array-into-equal-pairs/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2206.java) || Easy ||
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.HashSet;
6+
import java.util.List;
7+
import java.util.Set;
8+
import java.util.stream.Collectors;
9+
10+
public class _2215 {
11+
public static class Solution1 {
12+
public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {
13+
Set<Integer> set1 = Arrays.stream(nums1).boxed().collect(Collectors.toSet());
14+
Set<Integer> set1Copy = new HashSet<>(set1);
15+
Set<Integer> set2 = Arrays.stream(nums2).boxed().collect(Collectors.toSet());
16+
set1.removeAll(set2);
17+
set2.removeAll(set1Copy);
18+
List<Integer> list1 = set1.stream().mapToInt(n -> n).boxed().collect(Collectors.toList());
19+
List<Integer> list2 = set2.stream().mapToInt(n -> n).boxed().collect(Collectors.toList());
20+
return new ArrayList<>(Arrays.asList(list1, list2));
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)