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

Commit831db2c

Browse files
add 1863
1 parent2e16942 commit831db2c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-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+
|1863|[Sum of All Subset XOR Totals](https://leetcode.com/problems/sum-of-all-subset-xor-totals/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1863.java)||Easy|Backtracking, Recursion|
1112
|1862|[Sum of Floored Pairs](https://leetcode.com/problems/sum-of-floored-pairs/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1862.java)||Hard|Math|
1213
|1861|[Rotating the Box](https://leetcode.com/problems/rotating-the-box/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1861.java)||Medium|Array, Two Pointers|
1314
|1860|[Incremental Memory Leak](https://leetcode.com/problems/incremental-memory-leak/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1860.java)||Medium|Math|
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.List;
5+
6+
publicclass_1863 {
7+
publicstaticclassSolution1 {
8+
publicintsubsetXORSum(int[]nums) {
9+
intsum =0;
10+
List<List<Integer>>subsets =subsets(nums);
11+
for (List<Integer>subset :subsets) {
12+
intxor =0;
13+
for (inti :subset) {
14+
xor ^=i;
15+
}
16+
sum +=xor;
17+
}
18+
returnsum;
19+
}
20+
21+
publicList<List<Integer>>subsets(int[]nums) {
22+
List<List<Integer>>result =newArrayList();
23+
backtracking(result,newArrayList(),nums,0);
24+
returnresult;
25+
}
26+
27+
voidbacktracking(List<List<Integer>>result,List<Integer>list,int[]nums,intstart) {
28+
result.add(newArrayList(list));
29+
for (inti =start;i <nums.length;i++) {
30+
list.add(nums[i]);
31+
backtracking(result,list,nums,i +1);
32+
list.remove(list.size() -1);
33+
}
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp