Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc86b148

Browse files
add 2215
1 parentbf90263 commitc86b148

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+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.Arrays;
5+
importjava.util.HashSet;
6+
importjava.util.List;
7+
importjava.util.Set;
8+
importjava.util.stream.Collectors;
9+
10+
publicclass_2215 {
11+
publicstaticclassSolution1 {
12+
publicList<List<Integer>>findDifference(int[]nums1,int[]nums2) {
13+
Set<Integer>set1 =Arrays.stream(nums1).boxed().collect(Collectors.toSet());
14+
Set<Integer>set1Copy =newHashSet<>(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+
returnnewArrayList<>(Arrays.asList(list1,list2));
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp