feat: add initial implementation of Cargo.toml, Cargo.lock, and lib.rs with subset_xor_sum function

This commit is contained in:
SquidSpirit 2025-08-18 20:48:40 +08:00
parent d4b56a88fd
commit c98ac83cf7
3 changed files with 21 additions and 0 deletions

View 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"

View File

@ -0,0 +1,6 @@
[package]
name = "sum_of_all_subset_xor_totals"
version = "0.1.0"
edition = "2024"
[dependencies]

View 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)
}
}