feat: 1863_sum_of_all_subset_xor_totals
This commit is contained in:
parent
bb0ae9bf73
commit
8ae5954097
7
1863_sum_of_all_subset_xor_totals/Cargo.lock
generated
Normal file
7
1863_sum_of_all_subset_xor_totals/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "sum_of_all_subset_xor_totals"
|
||||
version = "0.1.0"
|
6
1863_sum_of_all_subset_xor_totals/Cargo.toml
Normal file
6
1863_sum_of_all_subset_xor_totals/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "sum_of_all_subset_xor_totals"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
8
1863_sum_of_all_subset_xor_totals/src/lib.rs
Normal file
8
1863_sum_of_all_subset_xor_totals/src/lib.rs
Normal file
@ -0,0 +1,8 @@
|
||||
pub struct Solution;
|
||||
|
||||
impl Solution {
|
||||
pub fn subset_xor_sum(nums: Vec<i32>) -> i32 {
|
||||
let or_sum = nums.iter().fold(0, |acc, &num| acc | num);
|
||||
or_sum << (nums.len() - 1)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user