commit 0dc2bebb110f3e9c1e561c9ee1d7f8890543d389
parent 38025ba13dc953105bf207696885e21cdd7d122d
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Mon, 20 May 2024 21:26:39 +0200
Daily Problem
Diffstat:
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/Problems/1863.cpp b/Problems/1863.cpp
@@ -0,0 +1,19 @@
+class Solution {
+ public:
+ int subsetXORSum(const vector<int> &nums) const {
+ const int n = size(nums);
+ int res = 0;
+
+ for (uint16_t mask = 1; mask < (1 << n); mask++) {
+ uint16_t crnt = mask, acc = 0;
+ while (crnt) {
+ const uint8_t idx = countr_zero(crnt);
+ acc ^= nums[idx];
+ crnt ^= 1 << idx;
+ }
+ res += acc;
+ }
+
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -967,6 +967,7 @@ for solving problems.
| 1857 | Hard | [Largest Color Value in a Directed Graph](Problems/1857.cpp) |
| 1860 | Medium | [Incremental Memory Leak](Problems/1860.cpp) |
| 1861 | Medium | [Rotating the Box](Problems/1861.cpp) |
+| 1863 | Easy | [Sum of All Subset XOR Totals](Problems/1863.cpp) |
| 1870 | Medium | [Minimum Speed to Arrive on Time](Problems/1870.cpp) |
| 1873 | Easy | [Calculate Special Bonus](Problems/1873.cpp) |
| 1877 | Medium | [Minimize Maximum Pair Sum in Array](Problems/1877.cpp) |